If I run a code with the ipython %pdb magic enabled and the code throws an exception, is there any way to tell the code to continue executing afterwards?
e.g., say the exception is a ValueError: x=0 not allowed. Can I, in pdb, set x=1 and allow the code to continue (resume) executing?
I don’t think you can resume code post-mortem (i.e. the exception was actually raised, triggering invocation of the debugger). What you can do, is put breakpoints in your code where you have been seeing errors, and that allows you to change values, and continue the program avoiding the error.
Given a script
myscript.py:Which continually increments a counter, raising an error if it’s ever divisible by 4. But we have edited it to drop into the debugger under the error condition, so we might be able to save ourselves.
Run this script from IPython: