The Python Debugger (pdb)

To break into pdb from a running program, insert this right into your code:
import pdb; pdb.set_trace()

You will then be in the debugger prompt, where you can move up/down in your code (u/d), look at variables (p expression), or execute any Python syntax in the current context (eg. changing a variable). A list of debugger commands is here.

To print an object’s complete state, the following can be used:
pp vars(your_object)

Advertisements

4 thoughts on “The Python Debugger (pdb)

  1. Pingback: Dave: Winter Code Sprint 2012 « Review Board Student Blog

  2. Pingback: Review Board and the Django Debug Toolbar | Review Board Student Blog

  3. Pingback: Review Board Student Blog

  4. Pingback: Meeting Minutes (Sept. 28, 2014) | Review Board Student Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s