Skip to content

Instantly share code, notes, and snippets.

@fsiler
Last active October 16, 2017 23:43
Show Gist options
  • Save fsiler/7837a0df9f0a076017472d5f8ae63e9c to your computer and use it in GitHub Desktop.
Save fsiler/7837a0df9f0a076017472d5f8ae63e9c to your computer and use it in GitHub Desktop.
2017-10-14 Smajda

NOTE- this comes from Jon Smajda @smajda, who presented at PythonKC

My one cool Python trick from today:

When you're debugging some code, if you put this at the line you want to look at:

import pdb; pdb.set_trace()

You will be dropped into an interactive shell at that point in your code. For example:

> /Users/jon/Dropbox/docs/programming/python/talks/logging/people/validate_people.py(34)<module>()
-> stream_handler.setLevel(loglevel)
(Pdb) loglevel
40

If you pip install ipdb you can use this instead:

import ipdb; ipdb.set_trace()

And use the IPython debugger instead of the built-in Pdb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment