On Thursday, 27 December 2012 13:56:24 UTC+5:30, Chris Rebert wrote: > On Dec 25, 2012 6:06 PM, "Abhas Bhattacharya" <abhasbhat...@gmail.com> wrote: > > > > > > 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 > (http://www.python.org/dev/peps/pep-3130/ ) or similar, but that particular > proposal got rejected.
Thanks for telling that. I thought that there is a direct way, and now you have confirmed that there isn't. So, as I can see, Mitya's code can be a perfect way-around, although it will require another function. -- http://mail.python.org/mailman/listinfo/python-list