how to get name of function from within function?

Raymond Hettinger python at rcn.com
Sat Jun 4 05:49:14 EDT 2005


[Christopher J. Bottaro]
>> def myFunc():
>>   print __myname__
>> >>> myFunc()
>> 'myFunc'

Perhaps the __name__ attribute is what you want:


>>> def myFunc():
	print myFunc.__name__

>>> myFunc()
myFunc




More information about the Python-list mailing list