catching syntax errors via excepthook?
Hari Sekhon
sekhon.hari at googlemail.com
Mon Jul 3 07:33:38 EDT 2006
I've written an except hook into a script as shown below which works
well for the most part and catches exceptions.
import sys
def myexcepthook(type,value,tb):
do something
sys.excepthook=myexcepthook
rest of script.... (now protected by catchall exception hook)
I've been intentionally introducing errors into the code to try to test
it and while it catches import errors and other things, it doesn't catch
syntax errors.
Is there a way to get it to catch syntax errors?
Or is there a better way?
-h
More information about the Python-list
mailing list