I want to add pdb—the Python debugger—to my toolbox. What’s the best way to get started?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Here’s a list of resources to get started with the Python debugger:
- Read Steve Ferb’s article “Debugging in Python”
- Watch Eric Holscher’s screencast “Using pdb, the Python Debugger”
- Read the Python documentation for pdb — The Python Debugger
- Read Chapter 9—When You Don’t Even Know What to Log: Using Debuggers—of Karen Tracey’s Django 1.1 Testing and Debugging.
Method 2
Synopsis:
# epdb1.py -- experiment with the Python debugger, pdb import pdb a = "aaa" pdb.set_trace() b = "bbb" c = "ccc" final = a + b + c print final
Now run your script:
$ python epdb1.py (Pdb) p a 'aaa' (Pdb)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0