|
|
|
|
|
by hcarvalhoalves
4587 days ago
|
|
A good list of libraries, but please, don't use this in the middle of your code to set a break point: import pdb; pdb.set_trace();
There's a chance you forget this, check-in, and it ends in production. Use pdb facilities instead: $ python -m pdb <myscript>
Then set a breakpoint and continue: (Pdb) break <filename.py>:<line>
(Pdb) c
This is trivial to automate from any editor or command line, so you don't even have to guess the path to the file.EDIT: For the lazy, here's a script to set breakpoints from the command line and run your scripts: https://gist.github.com/hcarvalhoalves/7587621 |
|
- I have a ~/.python/sitecustomize.py file with the following:
# Start debug on Exception
import bdb import sys
def info(type, value, tb):
sys.excepthook = infoIt will start ipdb automatically in case of any exception on command line called scripts.
- I use the awesome pdb emacs package for debug interactivelly during bigger bug hunts (Also for dev too... It's very a nice tool)
- Buutt... I still find the "print dance" to be my first-to-use quick tool.
edit: Fixed pasted code