bound member functions ?

Quinn Dunkan quinn at chunder.ugcs.caltech.edu
Mon Oct 8 18:06:57 EDT 2001


On Mon, 8 Oct 2001 11:28:13 +0200, Achim Domma <achim.domma at syynx.de> wrote:
>
>"Steve Holden" <sholden at holdenweb.com> wrote in message
>news:gXdw7.3286$Sj2.69338 at atlpnn01.usenetserver.com...
>> Yes. The reference to the bound method will keep the object around as long
>> as you need it.
>
>Thanks, I love Python !!! ;-)

The method holds a reference to the class.  You can see for yourself:

>>> class A:
...  def m(self): pass
...
>>> m = A().m
>>> m
<method A.m of A instance at c78e4>
>>> dir(m)
['__doc__', '__name__', 'im_class', 'im_func', 'im_self']
>>> m.im_class
<class __main__.A at c00e4>
>>>



More information about the Python-list mailing list