[IPython-dev] Getting executed code

Frédéric Mantegazza mantegazza at ill.fr
Wed Nov 30 03:46:59 EST 2005

Le Mardi 29 Novembre 2005 21:22, Fernando Perez a écrit :

> > Is there a way to retreive the currently executed code ? The
> > ipshell.buffer contains the code, but in the case of a multiline code,
> > how can I know what is the current line executed, in my custom
> > exception handler ?
> At that point, you need to use python's exception inspection machinery.
> IPython feeds entire blocks for execution to the interpreter, so it can't
> know at what line the error occurred.  But that information is stored in
> the traceback objects, so you can retrieve it.  Look at ultraTB.py for
> details of how ipython builds that information for display.

Ok, thanks.


More information about the IPython-dev mailing list