Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
253 views

Python Debugger Cheatsheet

This Python debugger cheatsheet provides commands for getting started with the Python debugger (pdb), examining and moving around code, setting breakpoints, and manipulating the debugger. The cheatsheet lists common pdb commands like set_trace() to start the debugger from a script, print and where to examine the program state, next and step to move line-by-line, break to set breakpoints, and ! to treat a statement as Python code.

Uploaded by

v2k2apj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
253 views

Python Debugger Cheatsheet

This Python debugger cheatsheet provides commands for getting started with the Python debugger (pdb), examining and moving around code, setting breakpoints, and manipulating the debugger. The cheatsheet lists common pdb commands like set_trace() to start the debugger from a script, print and where to examine the program state, next and step to move line-by-line, break to set breakpoints, and ! to treat a statement as Python code.

Uploaded by

v2k2apj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Debugger Cheatsheet

Getting started Movement


start pdb from within a script: <ENTER> repeat the last command
import pdb;pdb.set_trace()
n(ext) execute the current statement (step over)
start pdb from the commandline:
python -m pdb <file.py> s(tep) execute and step into function

r(eturn) continue execution until the current function returns


Basics
c(ontinue) continue execution until a breakpoint is encountered
h(elp) print available commands u(p) move one level up in the stack trace
h(elp) command print help about command
d(own) move one level down in the stack trace
q(quit) quit debugger

Breakpoints
Examine
b(reak) show all breakpoints
p(rint) expr print the value of expr
b(reak) lineno set a breakpoint at lineno
pp expr pretty-print the value of expr
w(here) print current position (including stack trace) b(reak) func set a breakpoint at the first line of a func

l(ist) list 11 lines of code around the current line


l(ist) first, last list from first to last line number Manipulation
a(rgs) print the args of the current function !stmt treat stmt as a Python statement instead of a pdb command

by Florian Preinstorfer (nblock@archlinux.us) — version 1.0 — license cc-by-nc-sa 3.0


see https://github.com/nblock/pdb-cheatsheet for more information.

You might also like