exceptions (was Re: Perl is worse!)

Martijn Faassen m.faassen at vet.uu.nl
Mon Jul 31 08:11:48 EDT 2000


Alex Martelli <alex at magenta.com> wrote:
> "Martijn Faassen" <m.faassen at vet.uu.nl> wrote in message
> news:8m3f0o$hn6$1 at newshost.accu.uu.nl...
[snip]
>> """
>>      However I find that bugs come up on the damnedest things, break you
>> out of loops, cause problems all around and don't let you return to where
> you
>> were [in the algorithm], esp. when you use general catch all exceptions.
>> As Alex(?) said, you don't return to where you were so, to me, it seems
> quite
>> impossible to be able to catch /all/ bugs gracefully, ever.
>> """
>>
>> The answer to that is easy: No, of course not.

> Well, ok, not *ALL*.  But you can _design_ for that, to avoid corrupting the
> precious persistent data, and avoid wasting a lot of worktime by the user,
> under presence of MOST kinds of bugs...

Yes, but I'd classify that under 'ungraceful handling', as in "well, something
went wrong. I'm not really sure what exactly, though perhaps I can guess
it's X. Let's at least save state Y and bring the UI back to that
state, and go on; it should all be okay".

Perhaps your definition of graceful is different. Anyway, you can handle
almost all exceptions. I didn't presume Steve was complaining about that;
he was complaining it would become a mess. I tried to figure out why he'd
think that, and the only reason I could come up with was that he wanted his
code to continue in the face of *bugs* (either in the input data or in the
program itself). 

You can catch and handle even bugs in Python, and try to restore your
program to a reasonable state. If you use transactions, this can actually
be done quite gracefully sometimes. But I'd say the usual case isn't that
graceful; in the case of bugs by definition the program doesn't know
what went wrong exactly. 

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list