howto catch an Exception and still print the TraceBack?

Diez B. Roggisch deets at nospam.web.de
Wed Feb 1 10:03:15 EST 2006


Saizan wrote:

> In an event-driven application i'd like to keep the program alive
> regardless of any exceptions raised by the handlers, but still be able to
> debug them by reading the appropriate TraceBack from stderr. I can put
> something like:

See 

sys.exc_info()

The you can do:

try:
   ....
except: # catch all
   _, e, tb = sys.exc_info()
   print tb


Regards,

Diez






More information about the Python-list mailing list