How to get a unique function name for methods

Terry Reedy tjreedy at udel.edu
Fri Oct 30 00:37:29 EDT 2009


Christian Heimes wrote:
> Philip Guo wrote:
>> Does anyone know how to get this information either from a code object or
>> from a related object?  I am hacking the interpreter, so I have full access
>> to everything.
> 
> Does this help?
> 
>>>> class A(object):
> ...     def method(self):
> ...         pass
> ...
>>>> A.method.im_class
> <class '__main__.A'>

In 3.x, A.method is the function, not a wrapper, so this will not work.

But as I said before, if one has class A 'in hand', it seems pointless 
to go looking for it.




More information about the Python-list mailing list