Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# from http://stackoverflow.com/a/14776693/999193
import sys
def myexcepthook(type, value, tb):
import traceback
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import TerminalFormatter
tbtext = ''.join(traceback.format_exception(type, value, tb))
lexer = get_lexer_by_name("pytb", stripall=True)
formatter = TerminalFormatter()
sys.stderr.write(highlight(tbtext, lexer, formatter))
sys.excepthook = myexcepthook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment