function name

Emile van Sebille emile at
Wed Apr 28 20:50:26 CEST 2010

On 4/28/2010 11:44 AM Richard Lamboj said...
> Hello,
> is there any way to get the name from the actual called function, so that the
> function knows its own name?
> Kind Regards,
> Richi
ActivePython (ActiveState Software Inc.) based on
Python 2.6.1 (r261:67515, Dec  5 2008, 13:58:38) [MSC v.1500 32 bit 
(Intel)] on
Type "help", "copyright", "credits" or "license" for more information.
 >>> def test():pass
 >>> dir(test)
['__call__', '__class__', '__closure__', '__code__', '__defaults__', 
_', '__dict__', '__doc__', '__format__', '__get__', '__getattribute__', 
ls__', '__hash__', '__init__', '__module__', '__name__', '__new__', 
, '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
sshook__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 
, 'func_globals', 'func_name']
 >>> test.func_name


More information about the Python-list mailing list