How can I get the function's caller?

Steve Holden steve at
Thu Sep 14 13:20:23 CEST 2006

David wrote:
> 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, ....)
> 	dummy()
> 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
Skype: holdenweb
Recent Ramblings

More information about the Python-list mailing list