On 10/4/06, Dethe Elza <[EMAIL PROTECTED]> wrote:
You can take a look at sys.excepthook and see if that does what you
need.
For example:
>>> import sys
>>> def myhook(type, value, traceback):
... print 'type:', type
... print 'value:', value
... print 'traceback:', traceback
...
>>> sys.excepthook = myhook
>>> 1/0
type: <type 'exceptions.ZeroDivisionError'>
value: integer division or modulo by zero
traceback: <traceback object at 0x63fd0>
I hope that helps.
--Dethe
On 4-Oct-06, at 10:06 AM, Doug wrote:
>
> I'm interested in exploring a custom traceback error handler, but I
> can't figure out if it is possible. I'd like to do something like:
>
> #-----------------------------
> from mylibrary import *
> x = 7 / 0
> #-----------------------------
>
> such that I can control what happens when an unhandled exception is
> thrown. I want to put something in mylibrary. Now, I know I can:
>
> #-----------------------------
> import sys
> try:
> x = 7 / 0
> except:
> custom_handler(sys.exc_type , sys.exc_value, sys.exc_traceback)
> #-----------------------------
>
> but I don't want to surround all of my code in a try/except clause. Is
> this possible? Are there hooks into the standard interpreter's
> unhandled exception handling?
>
> Thanks for any hints,
>
> -Doug
>
>
>
in the Internet Age. --Dean Baker
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "edupython" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/edupython
-~----------~----~----~----~------~----~------~--~---
