What exactly are bound methods?
Skip Montanaro
skip at pobox.com
Sun Nov 23 22:41:20 EST 2003
Ben> Although I see lots of references to them in various documentation,
Ben> I can't find a decent explanation of exactly what they are. I'm
Ben> guessing that it's a reference to a method that remembers which
Ben> object it came from, and that when it's called, it passes that
Ben> object as the first parameter (which would conventionally be
Ben> 'self'). Is this correct?
When you define a class like so:
class foo:
def bar(self):
pass
foo.bar is an unbound method. Binding the method associates it with a
particular instance. You can think of a bound method as currying the
instance object with the unbound method. For info on currying, check the
Python Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549
Skip
More information about the Python-list
mailing list