Phillip J. Eby wrote:
> At 02:48 PM 7/7/2005 -0400, Tim Peters wrote:
>>I also suspect that if they weren't in the language already, a PEP to
>>introduce them would fail, because
>>
>> still_looking = True
>> some loop:
>> if found it:
>> still_looking = False
>> break
>> if still_looking:
>> # what would have been in the "else" clause
>>
>>is clear and easy to write without it.
>
>
> *shudder* Okay, you just convinced me. "Else" should stay, because the
> above is much less readable and writable!
I think Aahz's point is a good one - conditional flow control can be most
clearly represented using try blocks:
class BreakException(Exception): pass
try:
some loop:
if found it:
raise BreakException
except BreakException:
pass
else:
# What would have been in the else clause
Defining 'else' on loops as short-hand for the above may make the intent of
the clauses clearer (that is, for/else and while/else are more closely related
to try statements than they are to if statements).
Regards,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.blogspot.com
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com