PdbCommands
Physics91SI,Spring2013
RexGarlandandGabeEhrlich
StartupandHelp
python -m pdb <name>.py[args] beginthedebugger
help [command] viewalistofcommands,orviewhelpforaspecific
command
withinapythonfile:
import pdb
...
pdb.set_trace() beginthedebuggeratthislinewhenthefileisrun
normally
NavigatingCode(withinthePdbinterpreter)
l(ist) list11linessurroundingthecurrentline
w(here) displaythefileandlinenumberofthecurrentline
n(ext) executethecurrentline
s(tep) stepintofunctionscalledatthecurrentline
r(eturn) executeuntilthecurrentfunctionsreturnis
encountered
ControllingExecution
b [#] createabreakpointatline[#]
b listbreakpointsandtheirindices
c(ontinue) executeuntilabreakpointisencountered
clear[#] clearbreakpointofindex[#]
ChangingVariables/InteractingwithCode
p <name> printvalueofthevariable<name>
!<expr> executetheexpression<expr>
NOTE:thisactsjustlikeapythoninterpreter
run [args] restartthedebuggerwithsys.argvarguments[args]
q(uit) exitthedebugger