Get the name of a function

Emile van Sebille emile at fenx.com
Fri Aug 5 16:19:30 EDT 2011


On 8/5/2011 11:52 AM gervaz said...
> Hi all, is there a way to retrive the function name like with
> self.__class__.__name__?

yes, but not reliably:

Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> def test():pass
...
 >>> test.__name__
'test'
 >>> b=test
 >>> b.__name__
'test'
 >>>


Emile





More information about the Python-list mailing list