finding out the call (and not only the caller)

Carl Friedrich Bolz cfbolz at gmx.de
Sun Oct 28 16:42:42 EDT 2007


Hi Neal,

nnorwitz at gmail.com wrote:
> The code doesn't handle all the cases (e.g., nested functions), but
> gives you an idea of what can be done and where to look for the info
> (ie, in the stack frame and how to parse the byte codes to some
> extent).  For nested functions, look in co_consts.
> 
> Bytecodes are specific to CPython.  This code won't work on
> IronPython, Jython, or PyPy.  This code really shouldn't be used for
> production.  However, it demonstrates some of the info available.

Actually that's not true for PyPy. PyPy uses CPython's bytecode, so the 
example works just fine.

Cheers,

Carl Friedrich Bolz




More information about the Python-list mailing list