[Tutor] Universal error handler
Emily Fortuna
emily.fortuna at nist.gov
Tue Jun 20 20:06:08 CEST 2006
Hi Matti!
Chances are you may have already seen this, but here are a list of the
different Python errors you can catch:
http://www.python.org/doc/1.5.2p2/api/standardExceptions.html
> Just started learning Python, and I was wondering if there is a way to
> catch an error or errors (like EOFError) whenever it occures during the
> script? The script (the program) wouldn't have any handling for that
> error itself, but a seperate block would handle that at the start or the
> end of the file.
Perhaps you have some other reason for putting the try/except pair
outside of the main function, (Other discussion welcome on this; I am
sure there are much more experienced programmers and software design
enthusiasts than I.) but I might suggest that you consider just putting
the specific lines that you think will catch the error in the try block,
rather than the whole main function. This way you will know much more
specifically what is causing the error, and you can handle different
errors more specifically.
HTH,
Emily
More information about the Tutor
mailing list