why no "do : until"?

Tim Gahnström com at gahnstrom.se
Sat Dec 30 15:58:14 EST 2000


>>next you gonna tell us that it's better to use flags than to use break
and/or
>>exceptions...
>
>    No, but I don't think that when you can place the test into the while
that
>one should use a while 1:break construct.


Chill folks, I am new to this group and I dont want a bad first impression
:-)

The original code was this

--
do :
    R=Themistor.ReadResistance()
    T=R_to_Temperature(R)
  until (T >=25)
--

The only way to acieve this exact behavior with is while is like this
-
a=1
while a=1 or (T >=25)
    a=0
    R=Themistor.ReadResistance()
    T=R_to_Temperature(R)
-

It is verry rare that we have to do it like this.
but the initial value of T might be used in ReadREsistance or in
R-to-temperature.

We have seen a few solutions that will be better in 99 cases of 100 but not
always.

Tim




More information about the Python-list mailing list