while (a=b()) ...

Gordon McMillan gmcm at hypernet.com
Sat May 15 12:15:38 EDT 1999


Magnus writes:

> Well ... IMNSHO, the while 1-idiom is just a symptom of too weak
> control structures, or bad structuring of the code <wink>.

Then use a constant in inverse proportion to the endlessness of the 
loop <wink wink>.

 while 1:    # an endless loop
    WorkerThread(serversock.accept()).run()

 while 2:    # a breakable loop
    <blah blah>
    if <cond>:
      break

preferring-idiotic-idioms-over-sorry-syntax-ly y'rs

- Gordon




More information about the Python-list mailing list