Skip to content

Instantly share code, notes, and snippets.

@davidalbertonogueira
Last active August 16, 2016 10:39
Show Gist options
  • Save davidalbertonogueira/4b0e04a0fd9424b9c5c29be2262ae61c to your computer and use it in GitHub Desktop.
Save davidalbertonogueira/4b0e04a0fd9424b9c5c29be2262ae61c to your computer and use it in GitHub Desktop.
Grab python error and start a debug session
import os
import sys
import pdb
import traceback
try:
your code here
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
@davidalbertonogueira
Copy link
Author

davidalbertonogueira commented Aug 16, 2016

For starting a debug session on a certain if clause:

if clause:
    import pdb
    import traceback
    traceback.print_exc()
    pdb.set_trace()

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