[Python-ideas] "while:" for the loop
Mark E. Haase
mehaase at gmail.com
Wed Sep 26 09:46:13 EDT 2018
On Tue, Sep 25, 2018 at 8:47 PM Mikhail V <mikhailwas at gmail.com> wrote:
> As for statistics - IIRC someone gave statistics once, but the only
> thing I can remember -
> "while 1/True" is used quite a lot in the std lib, so the numbers
> exceeded my expectation
> (because I expected that it's used mostly in algorithms).
This proposal would be a lot stronger if you included those statistics in
this thread and showed examples of stdlib code before/after the proposed
The meaning of "while" in natural language suggests a period of time or
condition. It does not mean "forever". Therefore, it's not a good semantic
fit. Python has shown a willingness to introduce new keywords: "async" and
"await" were added in Python 3.5, which was released about 3 years ago. I
imagine that a new loop keyword could be introduced in a
If you dislike the look of `while True:`, you can almost always hide it
inside a generator and use a `for … in …` block with clearer meaning.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas