Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>Ron Adam wrote:
>> True, but I think this is considerably less clear. The current for-else
>> is IMHO is reversed to how the else is used in an if statement.
>nope. else works in exactly the same way for all statements that
>support it: if the controlling expression is false, run the else suite
>and leave the statement.
For example, consider the behaviour of:
condition = False
if condition:
print "true"
else:
print "false"
and
condition = False
while condition:
print "true"
break
else:
print "false"
>From this, it's clear that while/else gets its semantics from if/else.
Then:
i = 0
while i < 10:
print i
i += 1
else:
print "Done!"
for i in range(10):
print i
else:
print "Done!"
So for/else behaves while/else, hence for/else really is the same way
round as if/else. It may not be "intuitive", but it's consistent, and
personally I'd rather have that.
--
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu become� se bera eadward ofdun hl�ddre heafdes b�ce bump bump bump
--
http://mail.python.org/mailman/listinfo/python-list