finding out the call (and not only the caller)

Carl Friedrich Bolz cfbolz at
Sun Oct 28 21:42:42 CET 2007

Hi Neal,

nnorwitz at 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.


Carl Friedrich Bolz

More information about the Python-list mailing list