The Samurai Principle

Grant Edwards invalid at invalid.invalid
Wed Sep 8 10:44:12 EDT 2010


On 2010-09-08, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> On Tue, 07 Sep 2010 20:35:45 -0700, Phlip wrote:
>
>> Exceptions are very dangerous by themselves, because if you don't trap
>> them just right they can cause side-effects.
>
> Huh?
>
> If you don't trap them just right, they cause a stack trace,

Not always.  That is the effect of not trapping them at all. 
However, you can trap them incorrectly -- which can result in
hard-to-track down problems.

The main example of this is a "bare except" clause that not only
catches and handles the "expected" exception but also catches (and
mishandles/ignores) an unexpected one.

> which is a side-effect I suppose. But it's an *intended* side-effect,
> since the alternative would be a core dump (or worse, an incorrect
> program that *doesn't* crash). This is a good thing!

-- 
Grant Edwards               grant.b.edwards        Yow! -- I have seen the
                                  at               FUN --
                              gmail.com            



More information about the Python-list mailing list