Python can be debugged without changing code
Debugging python code seems to be a trivial task, just paste the following lines to start the debugger.
import pdb
pdb.set_trace()
Yes, so I tried this and it works really well. It is a decent debugger.
But is it possible to run an unmodified python program, perhaps by specifying a text file, specifying breakpoints? This is how I usually do it in Java or Flash.
+3
Bryan hunt
source
to share
2 answers
Save the file with a name .pdbrc
in the same folder as your script file. Paste your control information into it:
b 3
b 5
b 70
b 89
Run your script in pdb like this:
python -m pdb myscript.py
and pdb fetch and insert your breakpoints. Unfortunately, it won't save any changes you make to it while debugging.
Alternatively, you can specify them on the first line
(Pdb) b 3;;b 5;;b 70;;b 89
+6
fraxel
source
to share
As the documentation explains , you can start it with:
python -m pdb myscript.py
+5
geoffspear
source
to share