Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active July 8, 2016 06:12
Show Gist options
  • Save nepsilon/a9c14d28706ebc368f8c to your computer and use it in GitHub Desktop.
Save nepsilon/a9c14d28706ebc368f8c to your computer and use it in GitHub Desktop.
How to debug Python programs? — First published in fullweb.io issue #35

How to debug Python programs?

When we can’t understand the execution path or behaviour of our program we better use a debugger. Python offers pdb, a full featured debugger. Here is how to get started.

Import it with:

import pdb 

Set a breakpoint with:

pdb.set_trace()
# The script execution will then stop
# and let you debug.

You can also trace full program with:

python -m trace --trace my_program.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment