Skip to content

Latest commit

 

History

History

import pdb; pdb.set_trace()

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

import pdb ; pdb.set_trace()

By Trey Hunner

The file pdb_demo.py is an interactive demonstration of pdb usage. The demo will teach you how to use some of the pdb commands shown below. To try out this demo run it in your Python interpreter:

python pdb_demo.py

This talk started with a demonstration of using pdb to locate a bug in a Django model method. A re-enactment of the demonstration is available on ascii.io.

PDB Commands

Below are the pdb commands I usually use. The characters in parenthesis are optional (so n and next to the same thing):

  • s(tep)
  • n(ext)
  • c(ontinue)
  • l(ist)
  • r(eturn)

Here are some more useful commands:

  • a(rgs)
  • pp: pretty print
  • (q)uit
  • (b)reak

Introspection

Some functions that are generally useful for introspecting Python code:

Alternative Debuggers

Some IDEs (PyCharm for example) have built-in Python debuggers that you can use. For more information on alternative debuggers and debugging in your IDE, check out the Python Debugging Tools link below.

More Resources