Python Debugger Cheatsheet

This is the most straightway to debug Django I have found so far.

In the Django script, import the debugger module.

import pdb

Start with the following code to enable the debugger.

pdb.set_trace()

The the following commands can be used in the Terminal.

Command Legend
h(elp) print all available commands
h(elp) command print help about the command
q(uit) quit debugger
p(rint) expr print the result of expr
pp expr pretty-print the result of expr
w(here) print current position
l(ist) list 11 lines of code around the current line
l(ist) first, last list lines from to last line number
a(rgs) print the args of the current function
n(ext) continue to next line
c(ontinue) continue to next breakpoint

Comments

Popular Posts