Created
September 20, 2015 20:17
-
-
Save alexrudy/bfa7354f56e34d1a7e88 to your computer and use it in GitHub Desktop.
IPython Debugger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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