PEP 315: Enhanced While Loop

Terry Reedy tjreedy at udel.edu
Mon May 5 12:33:16 EDT 2003


"Andrew Koenig" <ark at research.att.com> wrote in message
news:yu99isspv9mm.fsf at europa.research.att.com...
> By implication, there is no obvious reason that one could not write
>
>         while <condition1>:
>             <code1>
>         and while <condition2>:
>             <code2>
>         and while <condition3>:
>             <code3>

To me, this is the best alternative (to the current idiom) so far.  No
new keyword, no ambiguity about where block begins and ends.  However,
the actual execution flow is still not necessarily clear.  Reading
this naively, I would expect the loop to continue, and <code1> to
continue to be executed, until <condition1> was false.  Or something
like that.

> which would be equivalent to
>
>         while <condition1>:
>             <code1>
>             if not (<condition2>): break
>             <code2>
>             if not (<condition3>): break
>             <code3>
>
> Looking at these examples, I find myself liking the "and while" idea
more,
> because it uses (negative) indentation to mark the possible exit
points.

  I am beginning to like explicit breaks more.

Terry J. Reedy








More information about the Python-list mailing list