Over a million developers have joined DZone.

Python : Redirect Exceptions Hook

·

import sys, traceback, string

def myExceptHook(type, value, tb):
   sys.__excepthook__(type, value, tb)
   lines = traceback.format_exception(type, value, tb)
   print string.join(lines)

sys.excepthook = myExceptHook
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}