Getting class name

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Fri Aug 29 15:26:47 EDT 2003


Andreas Neudecker wrote:
> Is there a similar solution to get the name of the function or method 
> you are currently "in"?

Google, "python name of current function", I'm feeling lucky.

Or if you're using Python 2.3+ :

 >>> import inspect
 >>> def foo():
...   return inspect.getframeinfo(inspect.currentframe())[2]
...
 >>> foo()
'foo'
 >>>

--Irmen de Jong





More information about the Python-list mailing list