Fwd: Should I use "if" or "try" (as a matter of speed)?
Dark Cowherd
darkcowherd at gmail.com
Tue Jul 12 22:34:16 EDT 2005
OK, I can see that the Python way of doing things is very different.
However I think Roy made a very pertinent point
"Imagine if do_setup_code or
do_stuff_with(f) unexpectedly threw an IOError for some reason totally
unrelated to the file not existing."
This is the kind of situation that the rule 'catch it on the next
line' is trying to avoid
What I didnt realise till I read Thomas comment is that the try except
had an else clause. This is nice.
But seriously, if you expected to write reasonably large business
applications with multiple people in the team and teams changing over
time what would you give as a guideline for Error handling
DarkCowherd
More information about the Python-list
mailing list