Category Archives: Python

Python Debugger

It’s pretty simple to have your python script jump out to the debugger.  Place these 2 lines right before where you want to start monitoring (otherwise, you’ll need to do a lot of stepping thru code).

import pdb
pdb.set_trace()

Some useful ones to remember are:

  • b: set a breakpoint
  • c: continue debugging until you hit a breakpoint
  • s: step through the code
  • n: to go to next line of code
  • l: list source code for the current file (default: 11 lines including the line being executed)
  • u: navigate up a stack frame
  • d: navigate down a stack frame
  • p: to print the value of an expression in the current context