How can I get the function's caller?

Steve Holden steve at holdenweb.com
Wed Sep 13 02:34:45 EDT 2006


David wrote:
> Inside a function I need to get the function's caller's name. How can I get
> it?
> 
> thanks in advance.
> 

The "function caller", like most objects in Python, needn't actually 
have a name. It could, for example, be a lambda stored as a list element.

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 
unreliable.

regards
  Steve
-- 
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 mailing list