Resolving declaring class of a method at runtime
Janne Härkönen
janne.t.harkonen at gmail.com
Thu Nov 15 06:01:27 EST 2007
Hello,
Is there a simple way to resolve declaring class of a method at runtime ?
Consider this simple example:
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class X:
... def x(self):
... pass
...
>>> class Y(X):
... def y(self):
... pass
...
>>> y = Y()
>>> y.x.im_class
<class __main__.Y at 0x7ff24bfc>
>>> y.y.im_class
<class __main__.Y at 0x7ff24bfc>
What I would like to find out is the declaring class of method x, ie. class X
How to do this ?
--
__janne
More information about the Python-list
mailing list