Another of those "is" issues.
Benjamin Peterson
benjamin at python.org
Fri Mar 20 14:34:39 EDT 2009
Emanuele D'Arrigo <manu3d <at> gmail.com> writes:
>
> >>> class MyClass(object):
> ... def myMethod(self):
> ... pass
> ...
> >>> c = MyClass()
> >>> m = c.myMethod
> >>> m is c.myMethod
> False <--- What? Why is that?
>
> Can anybody shed some light? Or point to a resource to look at? Or
> what's the bit of python's source code that is responsible for dealing
> with those assignments?
Functions are descriptors (they have a __get__ method). Thus, every time a
method is resolved, a new bound method object is created with the object passed
to it.
More information about the Python-list
mailing list