Python exception hook simple example needed

fowlertrainer at anonym.hu fowlertrainer at anonym.hu
Wed Jul 6 05:23:52 EDT 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)
   else:
      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.
      pdb.pm()

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 benjiyork.com>
> Dátum:
> Tue, 05 Jul 2005 10:34:23 -0400
> Címzett:
> python-list at python.org
>
> Címzett:
> python-list at python.org
>
>
> fowlertrainer at anonym.hu 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