for what are for/while else clauses

Erik Max Francis max at alcyone.com
Sat Nov 15 08:40:59 CET 2003


Michele Simionato wrote:

> I personally consider the "else" clause a wart of Python.
> I never remember exactly what it is doing, and I have to look at the
> manual each time; moreover I don't see it giving any significant
> advantage
> to the language (other languages live very well without). So, I would
> be
> happy to have it removed, even if I am sure it will never happen :-(
> Am I the only one who think so?

I actually like it, and have used it with the `for' and `while' control
structures (although I only recently found out it is also available with
`try' and had that functionality to EmPy).  For some reason I can always
remember what it does, even though I agree it's not very memorable.  I
will readily admit that `else' is not a particularly enlightening name
for the functionality it represents, but I'm not sure I could come up
with a one-word substitute that would be much more enlightening.

I do think it is highly ironic that a unified try...except...finally
construct was removed because it was allegedly not intuitive enough, but
for...else, while...else, and even try...except...else (!) stayed with
no such complaint.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ 
\__/ There's this perfect girl / Someone no one can see
    -- Lamya




More information about the Python-list mailing list