why no "do : until"?

Rainer Deyke root at rainerdeyke.com
Sat Dec 30 06:23:26 CET 2000


"Steve Lamb" <grey at despair.rpglink.com> wrote in message
news:slrn94qqvg.mgg.grey at teleute.rpglink.com...
> On Fri, 29 Dec 2000 21:52:21 -0700, Bjorn Pettersen <pbjorn at uswest.net>
wrote:
> >henry_crun3583 at my-deja.com wrote:
> >> do :
> >>     R=Themistor.ReadResistance()
> >>     T=R_to_Temperature(R)
> >>   until (T >=25)
>
> >while 1:
> >   R=Themistor.ReadResistance()
> >   T=R_to_Temperature(R)
> >   if T >=25: break
>
>     Or, for those who don't like while 1:
>
> while T < 25:
>   R=Thermistor.ReadResistance()
>   T=R_to_Temerature()

T doesn't necessarily exist the first time 'T < 25' is evaluated above.
You'd need something like this:

T = 25
while T < 25:
  ...

At that point it's better to use 'while 1', which is at least idiomatic and
explicit in its inelegance.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list