while (a=b()) ...

Magnus L. Hetland mlh at idt.ntnu.no
Fri May 14 09:48:17 EDT 1999


spamfranke at bigfoot.de (Stefan Franke) writes:

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

What do you mean by "outnumbers its use for endless loops"? It can
only be used for endless (broken) loops -- because that is what
"while 1" means, no? So, having a separate keyword (like loop)
wouldn't change its uses at all... Please clarify -- maybe I'm just
slow here...

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

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

> 
> Stefan
> 

--

  Magnus
  Lie
  Hetland        http://arcadia.laiv.org <arcadia at laiv.org>




More information about the Python-list mailing list