How can I get the function's caller?
steve at holdenweb.com
Thu Sep 14 13:20:23 CEST 2006
> Il Wed, 13 Sep 2006 07:34:45 +0100, Steve Holden ha scritto:
>>What do you need this name for, just as a materr of interest? There are
>>ways of manipulating the stack frames, but they'll be slow and possibly
> I am writing a big (for me) program and it would be helpful to have a dummy
> function like this:
> def function_A_subfunction_B(self, ....)
> that display a standard message like this:
> "Dummy: 'function_A_subfunction_B' in module 'module' is not defined yet"
One way would be to have dummy() raise an exception, which it catches.
Then use the traceback information to provide the information you want.
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list