It seems that debugging python code is a trivial task, just insert the following lines to trigger the debugger.
import pdb
pdb.set_trace()
Yeah, so I tried that, and it works really well. It's a decent debugger.
But is it possible to launch an unmodified python program, perhaps specifying a text file, listing breakpoint locations? That's how I usually do it in Java or Flash.
Save a file called .pdbrc
in the same folder as your script file. Put in it your breakpoint information:
b 3
b 5
b 70
b 89
Run your script in pdb like so:
python -m pdb myscript.py
and pdb will pick up and insert your breakpoints. Unfortunetly it won't save any changes you make to them while debugging.
Alternatively you can specify them on the first line
(Pdb) b 3;;b 5;;b 70;;b 89
As explained in the documentation, you can run it with:
python -m pdb myscript.py
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