for what are for/while else clauses

Georgy Pruss see_signature__ at hotmail.com
Tue Nov 18 16:35:14 EST 2003


"Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:mailman.835.1069171329.702.python-list at python.org...
| <...>
| Or maybe this quote from a popular python book might help:
|
|     "Both the while and for statement may optionally have a trailing
|     else clause. The statement or statements after the else execute
|     when the loop terminates naturally (at the end of the for iterator
|     or when the while loop condition becomes false), but not when
|     the loop terminates prematurely (via break, return, or an exception).
|
| (the author seems to have rebooted since he wrote that, though.)
|
| </F>

The 'else' part of for/while is VERY useful and this is of course a big
plus for Python. But the name 'else' is VERY misleading and useless
and is probable even worse than 'static' in C++. That's exectly why
every week somebody asks this question here again and again.
I'm sure, even something like 'on_nornal_exit' would be much much better.

-- 
Georgy Pruss
E~mail: 'ZDAwMTEyMHQwMzMwQGhvdG1haWwuY29t\n'.decode('base64')






More information about the Python-list mailing list