while true: !!!

Delaney, Timothy tdelaney at avaya.com
Mon Dec 18 18:35:43 EST 2000

> >The idiom is actually
> >
> >while 1:
> >
> >	do something
> >
> >	if condition:
> >		break
> >
> >	do something else

> 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.

Personally, I agree with you - I was merely explaining *what* the idiom was
to someone who doesn't know.

I go well out of my way to avoid this idiom, as I feel you should always
have the termination condition at one end of the loop, preferably the top
(except in *Exception*al circumstances). For this reason, I would usually
use a Stream heirarchy of classes for handling files.

Tim Delaney
Avaya Australia

More information about the Python-list mailing list