Skip to content

Instantly share code, notes, and snippets.

@nahuel
Created September 15, 2014 17:58
Show Gist options
  • Save nahuel/6e821c93a8f829b3db01 to your computer and use it in GitHub Desktop.
Save nahuel/6e821c93a8f829b3db01 to your computer and use it in GitHub Desktop.
functools.partial
import functools
class A:
def __init__(s):
s.a = 1
def c(s,b,c,d):
print s.a,b,c,d
a = A()
a.c(2,3,4)
#=> 1 2 3 4
f = functools.partial(a.c, 2)
f(3,4)
#=> 1 2 3 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment