Skip to content

Debugging

image

IDE

Debugging through the IDE for at least Python and JavaScript is described here: Editor.

Python

Adding print statements will only get you so far. There’s a better way. It’s just as simple, actually.

Anywhere in your Python code, drop this line:

>>> import pdb; pdb.set_trace()

While running python, it just drops you in the debugger when the above statement is hit. The debugger is like a Python console, so inspecting or running code is like you’d expect it.

The behavior of pdb can be modified using ~/.pdbrc. The following example enables autocompletion in a pdb session:

import pdb
import rlcompleter
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete

Note that dev_appserver.py doesn’t allow loading .pdbrc.

When you’re done debugging, just hit c to continue code execution.

Behave

When you want to inspect things at breakpoint while running tests, you probably to use parameters like --no-capture --no-capture-stderr for allowing pdb interaction.