Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting breakpoint in pdb python

I want to set breakpoints using pdb and then run the loop in the program until that breakpoint. and then after checking the values keep continuing (only stopping at that point) until the loop ends. how do i do it?

like image 297
user3265370 Avatar asked Jan 29 '26 08:01

user3265370


2 Answers

You can run your program into pdb from the command line by running

python -m pdb your_script.py

This will stop execution at line 1, now set breakpoint with b linenumber e.g. b 25. Now type run it will run the program until that break point.

like image 108
Srinivas Reddy Thatiparthy Avatar answered Jan 30 '26 21:01

Srinivas Reddy Thatiparthy


If you can modify the code, one way is to add this line where you want to break:

import pdb; pdb.set_trace()
like image 41
R Samuel Klatchko Avatar answered Jan 30 '26 21:01

R Samuel Klatchko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!