Getting started with the Python debugger, pdb

PythonPdb

Python Problem Overview


I want to add pdb—the Python debugger—to my toolbox. What's the best way to get started?

Python Solutions


Solution 1 - Python

Here's a list of resources to get started with the Python debugger:

  1. Read Steve Ferb's article "Debugging in Python"
  2. Watch Eric Holscher's screencast "Using pdb, the Python Debugger"
  3. Read the Python documentation for pdb — The Python Debugger
  4. Read Chapter 9—When You Don't Even Know What to Log: Using Debuggers—of Karen Tracey's Django 1.1 Testing and Debugging.

Solution 2 - Python

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)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatthew RankinView Question on Stackoverflow
Solution 1 - PythonMatthew RankinView Answer on Stackoverflow
Solution 2 - PythonJosh GloverView Answer on Stackoverflow