[Python-Dev] Re: Dangerous exceptions (was Re: Another test_compilermystery)

Brett C. bac at OCF.Berkeley.EDU
Fri Oct 1 04:44:28 CEST 2004


Tim Peters wrote:
> After a bit more thought (and it's hard to measure how little), I'd
> like to see "bare except" deprecated.  That doesn't mean no way to
> catch all exceptions, it means being explicit about intent.  Only a
> few of the bare excepts I've seen in my Python life did what was
> actually intended, and there's something off in the design when the
> easiest thing to say usually does a wrong thing.
> 

Giving it same amount of thought as Tim, I like this idea as well.  I don't 
think the burden of having to always specify an exception to catch is that much 
work and would definitely be more explicit.  Plus it is not hard to teach to 
newbies; just tell them to catch the exception all of the "safe" exceptions 
inherit from.

Is it PEP time?  We have now had the idea of reorganizing the exception 
hierarchy come up in this thread and in early August (see 
http://www.python.org/dev/summary/2004-08-01_2004-08-15.html#an-exception-is-an-exception-unless-it-doesn-t-inherit-from-exception 
for the thread on reorganizing for the purpose of using new-style classes and 
the idea of having all raisable objects inherit from a specific base class). 
It seems like a serious enough of an idea that it will happen for Python 3000 
and thus should be discussed; never too early to start.  But maybe it at least 
deserves to be mentioned in PEP 3000 (Guido?)?

> Oh well.  We should elect a benevolent dictator for Python!
> 

Here, here!  =)

-Brett


More information about the Python-Dev mailing list