1.5.2 for: else:

Oleg Broytmann phd at emerald.netskate.ru
Tue Jul 27 08:34:27 EDT 1999


On Tue, 27 Jul 1999, Thomas Wouters wrote:
> http://www.python.org/doc/current/tut/node6.html#SECTION006200000000000000000
> 
> [..]
> 4.4 break and continue Statements, and else Clauses on Loops 
> 
> Loop statements may have an else clause; it is executed when the loop
> terminates through exhaustion of the list (with for) or when the condition
> becomes false (with while), but not when the loop is terminated by a break
> statement. 
> [..]
[skip]
> Else clauses get executed on normal loop exit, even if the loop was 'empty'.
> It does not get executed when you 'break' out of a loop.

   Aha, thanks. I expected "else" to be executed when "for" not executed on
empty list. Wrong assumption.

> -- 
> Thomas Wouters <thomas at xs4all.net>
> 
> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

Oleg.
---- 
    Oleg Broytmann        Netskate/Inter.Net.Ru        phd at emerald.netskate.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list