[Python-Dev] Bare except clauses in PEP 348

Guido van Rossum gvanrossum at gmail.com
Wed Aug 24 17:10:37 CEST 2005

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.

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.

--Guido van Rossum (home page: http://www.python.org/~guido/

More information about the Python-Dev mailing list