Skip to content

Instantly share code, notes, and snippets.

@simonthompson99
Last active February 29, 2024 10:46
Show Gist options
  • Save simonthompson99/36b150f18bb682830f31068c49bde8cf to your computer and use it in GitHub Desktop.
Save simonthompson99/36b150f18bb682830f31068c49bde8cf to your computer and use it in GitHub Desktop.
[Pudb Cheatsheet] Cheatsheet for pudb debugger #python

Running

python -m pudb <python_file> - opens up the script in pudb window, not executed anything yet. For fire modules better to make separate script that executes the individual function of interest, difficult to debug the original main file. Need pudb in virtualenv.

Or:

from pudb import set_trace
...
set_trace()

Then run script as usual, useful for debugging unitttest

? Gives all the keybindings, arrow keys navigates within window.

Controlling/navigating execution

Navigate with h,j,k,l,gg,G,C-u,C-d as per vim.

Shortcut Description
n execute script line by line
t execute up to cursor
b toggle breakpoint
c continue execution until breakpoint/exception/completion
s step into the function call
u move up execution stack
/ search in file ,/. to go next/previous

Browsing variables

Shortcut Description
`C v`
<space> expand/collapse
t/r/s show type/rep/str of variable
@ toggle repetition at top of pane
n add a new variable to watch

Other

Shortcut Description
m view module
e view exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment