Hey guys, don't give up your bare except clauses so easily.

They are useful.  And, if given the natural meaning of "catch
everything" and put in a natural position at the end of a suite, their
meaning is plain and obvious.  Remember beauty counts.  I don't think
there would be similar temptation to eliminate a dangling else clause
and replace it with "else Everything".  Nor would a final default case
in a switch statement benefit from being written as "default
Everything".

The thought is that it is okay to have useful defaults.  My whole issue
was that the PEP was choosing the wrong default.  If we leave it alone,
all is well.  An empty except will continue to mean "catch everything",
it will always appear at the end, its meaning will be obvious, and
existing working code won't break :-)

On the occasions where you really intended to catch everything, do you
really want to go on an editing binge just to uglify the code to
something like:

   try:                   
       ...
   except SomeException: 
       ...
   except BaseException:  
       ...


It is more beautiful and clear as:

   try:                   
       ...
   except SomeException: 
       ...
   except:  
       ...

To me, the latter is more attractive and is more obviously a catchall,
just like an else-clause or a default-statement.  It is a strong visual
cue that at least one of the except clauses will always be triggered.
In contrast, the first example makes you think twice about whether the
final case really does get everything (sometimes implicit IS better than
explicit).



Raymond

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to