I use Delphi in my day job and evaluating and learning Python over the
weekends and spare time. This thread has been very enlightening to me.
The comments that Joel of Joel on Software makes here
http://www.joelonsoftware.com/items/2003/10/13.html was pretty
convincing. But I can see from the
Dark Cowherd wrote:
But one advise that he gives which I think is of great value and is
good practice is
Always catch any possible exception that might be thrown by a library
I'm using on the same line as it is thrown and deal with it
immediately.
That's fine advice, except for when it's
Christopher Subich wrote:
try:
f=file('file_here')
except IOError: #File doesn't exist
error_handle
error_flag = 1
if not error_flag:
do_setup_code
do_stuff_with(f)
which nests on weird, arbitrary error flags, and doesn't seem like good
programming to me.
Neither
Christopher Subich [EMAIL PROTECTED] wrote:
try:
f = file('file_here')
do_setup_code
do_stuff_with(f)
except IOError: # File doesn't exist
error_handle
It's also a good idea to keep try blocks as small as possible, so you
know exactly where the error happened. Imagine if
Dark Cowherd [EMAIL PROTECTED] writes:
But one advise that he gives which I think is of great value and is
good practice is
Always catch any possible exception that might be thrown by a library
I'm using on the same line as it is thrown and deal with it
immediately.
Yuch. That sort of
Thomas Lotze wrote:
Neither does it to me. What about
try:
f=file('file_here')
except IOError: #File doesn't exist
error_handle
else:
do_setup_code
do_stuff_with(f)
(Not that I'd want to defend Joel's article, mind you...)
That works. I'm still not used to having