Python pdb - skip loop

How to skip a loop using pdb.set_trace() ?

For example,

 pdb.set_trace() for i in range(5): print(i) print('Done!') 

pdb asks before the loop. I enter a team. All values ​​1-5 are returned, and then I would like to receive a prompt with pdb before print('Done!') executed.

+63
debugging pdb
Jul 18 2018-11-11T00:
source share
4 answers

Try the until statement.

Go to the last line of the loop and use until . This will lead you to the next line, right after the loop.

http://www.doughellmann.com/PyMOTW/pdb/ has a good explanation

+103
Mar 25 2018-12-12T00:
source share

You should set a breakpoint after the loop ("break main.py:4", assuming the specified lines are in the main.py file), and then continue ("c").

+4
Oct 08 2018-11-11T00
source share

You can set another breakpoint after the loop and jump to it (when debugging) with c :

 pdb.set_trace() for i in range(5): print(i) pdb.set_trace() print('Done!') 
0
Jun 19 '19 at 8:02
source share

If I get you right.

One possible way to do this would be:

Once you get the pdb prompt. Just press n (next) 10 times to exit the loop.

However, I do not know how to exit the loop in pdb .

You can use r to exit the function.

-fifteen
Oct 07 2018-11-11T00:
source share



All Articles