faqts : Computers : Programming : Languages : Python : Snippets : Deep Magic

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 2 people (100%) answered Yes
Recently 2 of 2 people (100%) answered Yes

Entry

How can I get the name of the current function / function that called this one?

Jul 24th, 2002 11:02
Michael Chermside,


It's not generally a good programming technique, but there are some
cases (eg: logging framework) where it is very useful to be able to find
the name of the current function, or the function that called this one.
For an illustration of how, see Alex Martelli's recipe in the Python
Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062