variable inirialization and loop forms (was Re: why no "do : until"?)

Lloyd Sommerer lsommerer at ltec.net
Fri Jan 5 12:21:24 EST 2001


First of all, my hat is off to Alex Martelli for that interesting to read and
informative (at least to someone who knows as little as I do) evaluation of the
merits of various looping structures.

While I'm just learning Python, I was wondering if anyone knows a good reason
not to express a loop in this manner:

T = getCurrentTemperature()
while warmEnough(T):
    T = getCurrentTemperature()

This is expressed in Alex's generalization, but I think also applies to the
original code:

R=Themistor.ReadResistance()
T=R_to_Temperature(R)
while (T >=25):
    R=Themistor.ReadResistance()
    T=R_to_Temperature(R)

I realize that written this way there is a maintainability issue. Perhaps that's
reason enough not to do it this way.

Lloyd Sommerer





More information about the Python-list mailing list