[Tutor] Universal error handler
Matti Niemelä
matti at niemelat.net
Tue Jun 20 15:56:52 CEST 2006
Hi!
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.
For a simple 200 line script I made the whole thing into a function, and
at the end put:
def main():
# Do the program itself..
# The very end
try:
main()
except EOFError:
# Tell something went horribly wrong
I find this way of doing it disfunctional when having lots of code. Any
ideas?
- Matti
Finland
(Heh, first post to any newsgroup or any equivalent ever.. Hope this works!)
More information about the Tutor
mailing list