[Python-Dev] Bare except clauses in PEP 348

Brett Cannon bcannon at gmail.com
Thu Aug 25 03:43:23 CEST 2005


On 8/24/05, Guido van Rossum <gvanrossum at gmail.com> wrote:
> On 8/24/05, Michael Chermside <mcherm at mcherm.com> wrote:
> > Explicit is better than Implicit. I think that in newly written code
> > "except Exception:" is better (more explicit and easier to understand)
> > than "except:" Legacy code that uses "except:" can remain unchanged *IF*
> > the meaning of "except:" is unchanged... but I think we all agree that
> > this is unwise because the existing meaning is a tempting trap for the
> > unwary. So I don't see any advantage to keeping bare "except:" in the
> > long run. What we do to ease the transition is a different question,
> > but one more easily resolved.
> 
> OK, I'm convinced. Let's drop bare except for Python 3.0, and
> deprecate them until then, without changing the meaning.
> 

Woohoo!  I am currently on vacation before school starts (orientation
is Sept 1., classes start Sept. 6), so it might take me a little while
to edit the PEP, but I will try to fit into my schedule ASAP (assuming
the tide doesn't turn on me before then).

> The deprecation message (to be generated by the compiler!) should
> steer people in the direction of specifying one particular exception
> (e.g. KeyError etc.) rather than Exception.

Is there any desire for a __future__ statement that makes it a syntax
error?  How about making 'raise' statements only work with objects
that inherit from BaseException?

-Brett


More information about the Python-Dev mailing list