Loop until condition is true

Cyril BAZIN cyril.bazin at gmail.com
Tue Jun 21 13:39:44 CEST 2005


 Another question could be: why is there not a statement "whileTrue" or 
"loop"?

For exemple:

whileTrue:
statement 1
if condition:
break
statement 2


It could be an economy of one unuseful test by loop.

On 6/21/05, Magnus Lycka <lycka at carmen.se> wrote:
> 
> Remi Villatel wrote:
> > while True:
> > some(code)
> > if final_condition is True:
> > break
> > #
> > #
> >
> > What I don't find so "nice" is to have to build an infinite loop only to
> > break it.
> 
> This is a common Python idiom. I think you will get used to it.
> 
> 
> > Is there a better recipe?
> 
> final_condition = False
> while not final_condition:
> some(code)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050621/36c0e646/attachment.html>


More information about the Python-list mailing list