why no "do : until"?

Fredrik Lundh fredrik at effbot.org
Sat Dec 30 16:08:07 EST 2000


Steve Lamb wrote:
> On Sat, 30 Dec 2000 18:56:12 GMT, Fredrik Lundh <fredrik at effbot.org> wrote:
> >from what world do you come from where initializing variables to arbitrary
> >values just to get your program flow right is a good thing?
>
>     I have never heard of a single programming book or course that says, "Oh,
> don't init variables."  In this case I feel you are squarely in the wrong
> with, oh, the entire CS community.

Who said "don't init variables?"

Of course you should initialize a variable when it has a meaning-
ful initial value.

But in this case, the initial value is just something you made up
to get into the loop.  The temperature is never zero degrees (nor
minus 4711, or whatever) -- the initial value is just a flag value
that you use to get into the loop.

>     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.

What's the difference between using a special flag value, and a
separate flag variable?  I'd say it's the same thing...

(besides, no matter what you think, "do-while" is spelled "while
1-if-break" in Python.  no amount of arguing on comp.lang.python
will change that)

</F>





More information about the Python-list mailing list