How can I skip over a loop using pdb.set_trace()
?
For example,
pdb.set_trace() for i in range(5): print(i) print('Done!')
pdb
prompts before the loop. I input a command. All 1-5 values are returned and then I'd like to be prompted with pdb
again before the print('Done!')
executes.
from pdb, just type disable N, where N is the breakpoint number you are stuck on. If you don't know the number of your troubling breakpoint, enter tbreak. This will list your breakpoints by number under column "Num" and show whether (yes) or not (no) they are enabled or disabled under the column headed with "Enb."
pdb. set_trace (*, header=None) Enter the debugger at the calling stack frame. This is useful to hard-code a breakpoint at a given point in a program, even if the code is not otherwise being debugged (e.g. when an assertion fails). If given, header is printed to the console just before debugging begins.
Starting Python Debugger To start debugging within the program just insert import pdb, pdb. set_trace() commands. Run your script normally and execution will stop where we have introduced a breakpoint.
Try the until
statement.
Go to the last line of the loop (with next
or n
) and then use until
or unt
. This will take you to the next line, right after the loop.
http://www.doughellmann.com/PyMOTW/pdb/ has a good explanation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With