Resolving declaring class of a method at runtime

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Thu Nov 15 08:45:42 EST 2007


Janne Härkönen wrote:

>>>> 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 ?

The general idea of OOP is to not have to do this. I suspect you
have a problematic design. What's the problem you try to solve?

Regards,


Björn

-- 
BOFH excuse #105:

UPS interrupted the server's power




More information about the Python-list mailing list