Accessing method object from within a method

Vivek Sawant vivek_sawant at killspam.unc.edu
Wed Feb 18 15:54:50 EST 2004


Hi,

Is there a way to obtain the method/function object from within the 
method like 'self' refers to the object instance. I would like to avoid 
looking method name (string) in class/object attributes. My goal is to 
write code that need not be changed when the method name is changed.

def method (self, ...)
   # somehow obtain 'methodobj' for this 'method'
   mname = methodobj.__name__;
   # do something with mname

Thanks.
\vivek




More information about the Python-list mailing list