do...until wisdom needed...

Ken Peek Peek at LVCM.comNOSPAM
Mon Apr 16 00:44:08 EDT 2001


Sometimes, when writing code, I find it would be nice if there were a
"do...until" construct in Python.  This would be preferable to using a "while"
construct if you wanted to make sure the loop will execute at least once.  You
CAN do this with a "while" construct, but it requires fiddling with the loop
condition before the "while" construct, which is "messy".  An example:

condition = TRUE   # make sure loop runs at least once
while (condition):
    # do some stuff
    # do some more stuff
    condition = whatever_stops_the _loop

Here is my question--  If Python WERE to have a "do...until" construct, what
would be the best way to implement the syntactical rules?

For example:

do:
    # some stuff
    # some more stuff
    until (condition == TRUE)   # ("until" must be last statement or there is an
error)

OR:

do:
    # some stuff
    # some more stuff
until (condition == TRUE)

OR: ???






More information about the Python-list mailing list