frames and classes

Alex Martelli aleaxit at
Sat Nov 18 00:25:59 CET 2000

"Gil Hauer" <gilh at> wrote in message
news:8v426v$hkv$1 at
> Hi,
> I have a routine that is called as a result of the sys.settrace()
> One of the parameters is the call frame. I would like to know that name of
> the class to which the function being traced belongs -- is there any way
> do this?

I was looking for something similar recently and couldn't
solve it in a fully reliable way.  You can get the name of
the class of 'self' (assuming the convention of naming the
first parameter that way is respected -- or, of the first
parameter, at least!), but that is no guarantee -- the method
could be inherited, or explicitly delegated to.  Or, of course,
it could not be a method at all (not belong to any class).

I suspect the only solution will need some rooting through
the bytecode...


More information about the Python-list mailing list