Get Lanyrd on your mobile (iPhone, Android and more) - check it out here

Introduction to PDB

A session at PyCon US 2012

Friday 9th March, 2012

2:40pm to 3:20pm (PST)

PDB is an interactive debugging environment for Python programs. It allows you to pause your program, look at the values of variables, and watch program execution step-by-step, so you can understand what your program is actually doing, as opposed to what you think it's doing. This talk will show novice and intermediate Python users how to use PDB to troubleshoot existing code.

PDB is an interactive debugging environment for Python programs. It allows you to pause your program, look at the values of variables, and watch program execution step-by-step, so you can understand what your program is actually doing, as opposed to what you think it's doing.

Effectively using PDB is arguably the most important skill a new Python developer can learn. This talk will show novice and intermediate Python users how to use PDB to troubleshoot existing code.

When is it reasonable to use PDB?

"I don't use a debugger"

When is it really not reasonable?

Modes of pdb usage

set_trace mode, e.g. pdb.set_trace()

postmortem mode, e.g. python -m pdb buggy.py or pdb.pm()

run mode, .e.g. pdb.run('some.expression()').

Getting help

Shortcut aliases (c vs. continue)

The workhorse commands (list, print, pretty-print, next, continue, step, return, until, where, up, down):

list: displaying code in your current execution context

p and pp: displaying objects

continue, step, return, next, return, until: execution control

where: showing the current location in the frame stack

up, down: navigating the frame stack

Managing breakpoints (break, tbreak, ignore, enable, disable, clear):

break, tbreak, ignore, enable, disable, and clear: Managing breakpoints
Lesser-used commands (args, !-prefixing, debug)

debug: recursive debugging

!-prefixing: modifying variables

args: printing args to the current function

commands: scripting pdb

~/.pdbrc and PDB aliases

Debugging in the face of threads (ie. web apps).

"Purple bags"

Enhanced shells: ipdb, pudb, winpdb

In-editor debugger integration (Wing, Eclipse PyDev, PyCharm, etc)

About the speaker

This person is speaking at this event.
Chris McDonough

Python web developer bio from Twitter

Coverage of this session

Sign in to add slides, notes or videos to this session

Tell your friends!

When

Time 2:40pm3:20pm PST

Date Fri 9th March 2012

Short URL

lanyrd.com/spbzr

Official session page

us.pycon.org/…e/presentation/149/

View the schedule

Share

Topics

Books by speaker

  • Visual Basic 5 Fundamentals Unleashed (Vol 1)
  • Max Maven's Book of Fortunetelling
  • UFO Sightings: The Evidence

See something wrong?

Report an issue with this session