Skip to content

Instantly share code, notes, and snippets.

@kmcallister
Created May 14, 2012 18:54
Show Gist options
  • Save kmcallister/2695693 to your computer and use it in GitHub Desktop.
Save kmcallister/2695693 to your computer and use it in GitHub Desktop.
functools.partial on method
import functools
class Foo(object):
def __init__(self, name):
self.name = name
def add(self, x, y):
print '%s: %d + %d = %d' % (self.name, x, y, x+y)
obj = Foo('bar')
f = functools.partial(obj.add, 3)
f(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment