PEP 315: Enhanced While Loop
Dan Bishop
danb_83 at yahoo.com
Sat May 3 20:09:18 EDT 2003
"Ben Allfree" <benles at bldigital.com> wrote in message news:<mailman.1051973585.3998.python-list at python.org>...
...
> At one point, quite a few BASIC and Pascal flavors had a repeat..until
> or do..while loop construct. It seems that it faded away, and I'm not sure
> why.
Repeat...until is part of Standard Pascal, but hardly anyone uses
Pascal anymore.
For BASIC, the only flavor I've seen that had a posttest loop
construct (other than conditional GOTO) was QBasic, which had a
DO...LOOP block that allowed all 4 possible combinations of
pretest/posttest and WHILE/UNTIL, so your code could have been written
' option 1: pretest WHILE
' This could also be done by the older WHILE...WEND construct
MakeMoney
DO WHILE Poor()
MakeMoney
LOOP
' option 2: pretest UNTIL
MakeMoney
DO UNTIL NOT Poor()
MakeMoney
LOOP
' option 3: posttest WHILE
DO
MakeMoney
LOOP WHILE Poor()
' option 4: posttest UNTIL
DO
MakeMoney
LOOP UNTIL NOT Poor()
While this was a good syntax for a language that delimited blocks with
pairs of statements (e.g., FOR...NEXT, FUNCTION...END FUNCTION),
unfortunately it wouldn't work well in Python.
Personally, I'm satisfied with
while True:
MakeMoney()
if not Poor():
break
More information about the Python-list
mailing list