do ... while loop
Adrian Eyre
a.eyre at optichrome.com
Thu Oct 14 11:52:39 EDT 1999
> > while 1:
> > xxx
> > yyy
> > if not condition:
> > break
> Actually, Python is full of `while 1' loops. One gets used to them
> after a while (and my C loops with multiple exit points tend to have
> them too), but they're not really nice.
I disagree. It's often a lot clearer to say:
while 1:
if condition1:
break
if condition2:
break
do_something()
than:
while not (condition1 or condition2):
do_something()
> One wonders what's the point of having a condition in the while
> loop if you're not to use it. :-)
How about something like an old construct in GFA BASIC (anyone
remeber that?):
do: # Equivalent to while 1
if condition1:
break
if condition2:
break
do_something()
--------------------------------------------
Adrian Eyre <mailto:a.eyre at optichrome.com>
Optichrome Computer Solutions Ltd
Maybury Road, Woking, Surrey, GU21 5HX, UK
Tel: +44 1483 740 233 Fax: +44 1483 760 644
http://www.optichrome.com
--------------------------------------------
More information about the Python-list
mailing list