Python pdb Module
Example
Start the debugger for a simple function call:
import pdb
def myfunc(x):
return x.upper()
pdb.run('myfunc("Hello")')
Try it Yourself »
Definition and Usage
The pdb module is Python’s built-in debugger.
Use it to step through code, inspect variables, and set breakpoints during development and troubleshooting.
Members
Member | Description |
---|---|
Pdb | The main debugger class. Instantiate it for advanced control. |
post_mortem() | Start debugging from the point where an exception occurred. |
run() | Run a string of code under the debugger. |
runcall() | Call a function under the debugger. |
runeval() | Evaluate an expression under the debugger. |
set_trace() | Enter the debugger at the calling line (drop into an interactive session). |