pythondebuggingpdb

How do I skip a loop with pdb?


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.


Solution

  • 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.

    https://pymotw.com/3/pdb/index.html has a good explanation