how to get name of function from within function?

Raymond Hettinger python at rcn.com
Sat Jun 4 11:49:14 CEST 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