How to find instance of a bound method in Python?

Starting python 2.6 you can use special attribute __self__:

>>> a.some.__self__ is a
True

im_self is phased out in py3k.

For details, see the inspect module in the Python Standard Library.

Leave a Comment