Finding the name of a function while defining it

Chris Rebert clp2 at
Thu Dec 27 09:26:24 CET 2012

On Dec 25, 2012 6:06 PM, "Abhas Bhattacharya" <abhasbhattacharya2 at>
> While I am defining a function, how can I access the name (separately as
string as well as object) of the function without explicitly naming
it(hard-coding the name)?
> For eg. I am writing like:
> def abc():
>     #how do i access the function abc here without hard-coding the name?

Not possible per se without resorting to sys._getframe() or similar hackery.
A simple+elegant way to do this would require PEP 3130 ( ) or similar, but that particular
proposal got rejected.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list