while semantics

Erik Max Francis max at alcyone.com
Fri Mar 14 04:46:21 CET 2003


David Bear wrote:

> What about
> 
> while (condition):
>         do stuff
>         do more stuff
>         condition becomes true
>         do even more stuff
> 
> Will while terminate AS SOON as condition is true, or will it evaluate
> all
> statements in the block?

(I presume you mean "as condition is false" here.)  Once the condition
becomes false, it will evaluate the remaining statements in the block,
the while loop will test the condition, which will evaluate to false,
and then leave the control structure.  The condition is only tested upon
each entry into the block.  If it's true, the whole block is executed. 
If it's false, the while structure is done and it moves on.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ If I had known, I would have become a watchmaker.
\__/ Albert Einstein
    Bosskey.net / http://www.bosskey.net/
 A personal guide to online multiplayer first person shooters.




More information about the Python-list mailing list