The Python Debugger (pdb)
To break into pdb from a running program, insert this right into your code:
import pdb; pdb.set_trace()
You will then be in the debugger prompt, where you can move up/down in your code (u/d), look at variables (p expression), or execute any Python syntax in the current context (eg. changing a variable). A list of debugger commands is here.
To print an object’s complete state, the following can be used:
pp vars(your_object)
Categories: Developer Tips and Tricks
Recent Comments