On Fri, Jan 6, 2012 at 11:02 AM, dmitrey <dmitre...@gmail.com> wrote:
> hi all,
> how to get id(func) for each func in stack? (I mean memory address, to
> compare it with id(some known funcs))
> Thank you in advance, D.

The answer hasn't changed since your last thread about this.  The
stack contains code objects, not functions.  You can get the code
objects using inspect.stack(), and compare them to the func_code
attributes of the functions you're interested in.

Also, there's no need to use id() for this.  Just use the "is"
operator to check identity.

for frame_tuple in inspect.stack():
    frame = frame_tuple[0]
    if frame.f_code is some_function.func_code:
        print("Found it!")

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to