do...until wisdom needed...

Steve Lamb grey at despair.rpglink.com
Mon Apr 16 14:58:39 EDT 2001


On Mon, 16 Apr 2001 13:22:36 -0400, Benjamin.Altman <benjamin.altman at noaa.gov>
wrote:
>Ugliness aside, it would work since it is dependant on indentation.  In your
>example you
>would have to do:
>    while cond():
>        #bla
>        #bla
>        #bla
>
>            #do some stuff
>        until cond2()
>

    Please, no jeopardy quoting, it makes it hard to keep a discussion
readable.

>> Benjamin.Altman <benjamin.altman at noaa.gov> wrote in comp.lang.python:

>> So how would you put that after another block?
>>
>> while cond():
>>    #bla
>>    #bla
>>    #bla
>>
>>    #do some stuff
>> until cond2()

    No, he was asking a very valid question.  Take the following example.

for x in y:
    do_something()
while(1):
    do_another_thing()
    if condition:
        break

    Well, since we're discussing taking a while(1):...break and turning it
into a do..until /and/ your suggestion is to do a reverse off the until
keyword now translate the above block into your proposed syntax.

for x in y:
    do_something()
    do_another_thing()
until cond()

    Uhm, how do you tell the two loops apart?  AFAICT, he was not asking about
one loop nested inside another, he was asking about one loop following
another.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list