Python exception hook simple example needed

fowlertrainer at fowlertrainer at
Wed Jul 6 11:23:52 CEST 2005

Hi !

I think I found an example:

import sys

def info(type, value, tb):
   if hasattr(sys, 'ps1') or not sys.stderr.isatty():
      # we are in interactive mode or we don't have a tty-like
      # device, so we call the default hook
      print "yyy"
      sys.__excepthook__(type, value, tb)
      import traceback, pdb
      # we are NOT in interactive mode, print the exception...
      print "xxx"
      traceback.print_exception(type, value, tb)
      # ...then start the debugger in post-mortem mode.

sys.excepthook = info

But I don't know it is working or not....

Thanx: ft

> Tárgy:
> Re: Python exception hook simple example needed
> Feladó:
> Benji York <benji at>
> Dátum:
> Tue, 05 Jul 2005 10:34:23 -0400
> Címzett:
> python-list at
> Címzett:
> python-list at
> fowlertrainer at wrote:
>> If anyone has an idea, how to I catch exceptions globally, please 
>> write me.
> I believe there is an example of this in the demo that comes with 
> wxPython (don't have an install handy to check).
> -- 
> Benji York

More information about the Python-list mailing list