[Python-ideas] except expression
Jan Kaliszewski
zuo at chopin.edu.pl
Wed Feb 19 01:11:52 CET 2014
18.02.2014 17:43, Chris Angelico wrote:
> On Wed, Feb 19, 2014 at 3:25 AM, Paul Moore <p.f.moore at gmail.com>
> wrote:
>> Explicit is better than implicit - I think this discussion has done
>> its job and established that trying to assume a subset of exceptions
>> to catch isn't going to work. We either allow a bare except to mean
>> "catch all exceptions" (which exactly the same risks and provisos as
>> a
>> bare except *statement*) or we make the exception to catch
>> mandatory.
>
> Yep, agreed. I'm personally inclined to permit the bare except, and
> then advise against it in PEP 8, but both halves of that are
> debatable. I'm of the opinion that this would be risky:
IMHO bare except is practically always a very bad practice unless the
exception is immediately re-raised:
try:
foo()
except:
logger.exception('error:')
raise
...and AFAIK, up to now, nobody proposed any syntax that would make it
possible to re-raise an exception in an except expression.
Therefore I believe that bare except should *not* be allowed in
except expressions at all.
My-3-cents-ly yours
*j
More information about the Python-ideas
mailing list