Skip to content

Instantly share code, notes, and snippets.

@alexrudy
Created September 20, 2015 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexrudy/bfa7354f56e34d1a7e88 to your computer and use it in GitHub Desktop.
Save alexrudy/bfa7354f56e34d1a7e88 to your computer and use it in GitHub Desktop.
IPython Debugger
# -*- coding: utf-8 -*-
import sys
import warnings
_ipydb_active = False
def ipydb():
"""Try to use the iPython debugger on program failures."""
global _ipydb_active
if _ipydb_active:
return
try:
from IPython.core import ultratb
except ImportError:
warnings.warn("Not enabling IPython debugger because"
" 'IPython' isn't installed!")
else:
_file = getattr(sys.modules['__main__'], '__file__', '')
sys.excepthook = ultratb.ColorTB(color_scheme='Linux', call_pdb=1)
setattr(sys.modules['__main__'], '__file__', _file)
__ipydb_active = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment