while true: !!!

Blair Lowe Blair.Lowe at compeng.net
Mon Dec 18 03:19:51 EST 2000


At 11:03 +1100 2000/12/18, Delaney, Timothy wrote:
>This is precisely the reason this thread exists ...
>
>The idiom is actually
>
>while 1:
>
>	do something
>
>	if condition:
>		break
>
>	do something else
>
>Basically, it's for dealing with situations where you can't tell at the
>beginning or end of a loop if the loop is completed - only somewhere in the
>middle. The canonical example is


This is exactly what a python program should be NOT doing. "while 1" 
is one of the most cryptic statements in Computer Science. other 
languages are known for this stuff, but I do not know why python 
doesn't auto define true and false, so that we don't have to write 
unreadable stuff.

One of the points of this language is to DECRYPT some of the poor 
coding styles out there. The indentation rules are a good example.

While "while 1" (pardon the pun) is a standard fixture that anyone 
with any experience knows what is going on, the whole point is to 
make all our code readable so that we, and others can maintain it and 
reuse it easily.

Imagine the newbie looking at this statement: while 1 ... hmmm must 
be the first condition of a while loop ????

It is cheap to define true and false once, or (my favourite) define 
ever (;;). Although the definition is cryptic, the resulting code is 
very readable. That is what we want.

I find that some python programs have very little documentation yet 
they are simple enough to read that a SMALL reduction in 
documentation is possible unless we start writing perl and C in 
python.

>  >
>  > PS.  I haven't been following most of this thread, so forgive me if
>  > this has already come up.
>  >

ditto,

TTYL,
Blair.
Computer Engineering Inc. http://www.compeng.net
Phone: 780 499 5687 (9 - 5 MST) Fax:   780 435 0693 (24 Hours)




More information about the Python-list mailing list