isaac.morland at gmail.com
Mon Jul 24 13:12:45 EDT 2017
The way I remember it is to observe that the following are *almost* exactly
the same thing:
The *only* differences are:
1) where execution jumps if it reaches the end of the T: in the "while", it
jumps back to the while itself, resulting in the condition being rechecked,
whereas in the "if" execution skips over the "else" to whatever follows; and
2) in the "while", inside the T "break" and "continue" relate to this
control structure rather than to a containing loop.
(At least I don't think I'm missing any other differences!)
Seen this way, the meaning of the "else" is easy to understand and to
And the for loop else is like the while loop else.
On 24 July 2017 at 11:35, Kiuhnm via Python-Dev <python-dev at python.org>
> I think that the expression "for...else" or "while...else" is completely
> counter-intuitive. Wouldn't it be possible to make it clearer? Maybe
> something like
> break in for i in range(n):
> if cond:
> I'm not an English native speaker so I don't know whether "break in" is
> acceptable English in this context or can only mean "to get into a building
> by force".
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/isaac.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev