What exactly are bound methods?

Michele Simionato mis6 at pitt.edu
Tue Nov 25 07:02:23 CET 2003

kylotan at hotmail.com (Kylotan) wrote in message news:<153fa67.0311231859.551b673 at posting.google.com>...
> Although I see lots of references to them in various documentation, I
> can't find a decent explanation of exactly what they are. I'm guessing
> that it's a reference to a method that remembers which object it came
> from, and that when it's called, it passes that object as the first
> parameter (which would conventionally be 'self'). Is this correct?

If you really want to learn the difference between functions, methods 
and bound methods, you must learn descriptors:


Warning: the study of descriptors may cause your head to explode ...

>>> def f(self): pass
>>> class C(object): pass
>>> c=C()
>>> f.__get__(c,C)
<bound method C.f of <__main__.C object at 0x017716D0>>
>>> f.__get__(None,C)
<unbound method C.f>

More information about the Python-list mailing list