Minor Changes

Uncaught Exception Hook

  • sys.excepthook(type, value, traceback)
  • Called when an uncaught exception reaches the top level of the interpreter
  • Can be used to provide customized output (more debugging information)
     >>> def uncaught(type,value,tb):
     ...      print "Guru meditation error. %x" % id(type)
     ...
     >>> sys.excepthook = uncaught
     >>> s
     Guru meditation error. cc724
  • More practical use - specialized error handling
  • CGI scripts, embedded systems, debuggers, etc.
<<< O'Reilly OSCON 2001, New Features in Python 2, Slide 46
July 26, 2001, beazley@cs.uchicago.edu
>>>