who is my caller?
Emile van Sebille
emile at fcfw.fenx.com
Tue Mar 27 10:24:41 EST 2001
It appears you can get to the callers locals and globals. Looking at
traceback, you find sys.exc_info(), which leads to [2].tb_frame which gets
you to f_locals and f_globals.
Emile van Sebille
emile at fenx.com
---------
----- Original Message -----
From: "Clark C. Evans" <cce at clarkevans.com>
To: "Emile van Sebille" <emile at fenx.com>
Cc: <python-list at python.org>
Sent: Tuesday, March 27, 2001 7:15 AM
Subject: Re: who is my caller?
> On Tue, 27 Mar 2001, Emile van Sebille wrote:
> > If I'm not mistaken, with 2.0 you can directly import traceback without
> > needing to generate an exception first.
>
> I was actually looking to do something like..
>
> caller = traceback.call_stack.top()
> try:
> if '0h3kfd' = caller.check('key'):
> # ok... you passed security
> except:
> pass
>
> A string print-out is useless... I'm after
> the function objects....
>
> This brings up another question, if I
> have a function can I get the module
> handle; or if I have a bound-function can
> I fetch the object that it is part of?
>
> Thanks!
>
> Clark
>
>
>
>
More information about the Python-list
mailing list