PEP-315 ("do" loop)

Paul Prescod paul at
Tue Feb 17 16:50:53 CET 2004

Wayne Folta wrote:

> ...  How about, instead, creating an "until" loop:
> until line == "\n":
>     line = sys.stdin.readline()
> Would be defined to work exactly like a while loop except the test is 
> not evaluated the first time through the loop. Wouldn't this be akin to 
> checking at the end of the loop, while maintaining a more while-ish syntax?

is maintaining a while-ish syntax the right thing to do? After all, the 
"until" code is conceptually evaluated at the bottom, not the top of the 
loop. I would naively think that "until" is just a "while" that inverts 
its condition. i.e.

until x <==> while not x

Nothing about the word "until" implies to me that it delays the loop 
test on the first go-round. PEP 315's syntax seems more clear to me.

  Paul Prescod

More information about the Python-list mailing list