while (a=b()) ...

Stefan Franke spamfranke at bigfoot.de
Wed May 12 11:55:17 EDT 1999


>Paul Boddie <paulb at infercor.no> wrote:
> Of course, the "while 1" is a bit "ugly", but then it merely causes the
> reader to go looking for the exit points. We could change that to a
> single keyword acting as a synonym if it really bothered a significant
> number of people, but I don't see too much of a need for that.

I would even go further: The use of "while 1:" as a substitute for other control
structures outnumbers its use for endless loops *by far* (at least 20:1 in the
standard libs, as a quick grep shows).

So IMO this idiom should be taught as early as possible, Unluckily the Python
tutorial mentions "while 1:" only three times: Two times for endless loops, one
time to demonstrate syntax errors...

Stefan





More information about the Python-list mailing list