Sonntag, 3. Januar 2016

using pdb from within Ipython

Start your script from within Ipython
%run yourscript.py
While debugging exeptions, I prefer this over embedding ipython,
because the shell stops right after the exception is thrown.

When the exception is thrown, you get a stack trace, showing the exception.
Now enter the python debugger from within ipython
%debug
You can now use all the pdb features (pdb commands) as well as ipython functionality (think tab completion).

Walk up the stack trace until you get to your faulty code
u

edit your code in your favourite editor (outside ipython)

reload the changed code
%load_ext autoreload
%autoreload 2
Test the changed code, by rerunning the changed function or script.

That's how it should work. Somehow it doesn't for me. The same error gets thrown, although ipython shows the corrected code in the stack trace.
After restarting ipython it works fine ...

Keine Kommentare:

Kommentar veröffentlichen