On Fri, 11 May 2018 01:51:47 +0300, Marko Rauhamaa wrote:
> Paul Rubin <[email protected]>:
>
>> Marko Rauhamaa <[email protected]> writes:
>>> It turns out "while True" is the most natural choice in about half of
>>> the while loops.
>>
>> Maybe the rest would be "repeat until" if Python had that?
>
> No. "Repeat until" is a relatively infrequent need.
And again, YMMV. In my experience, most "while True" loops would be
better off written as a "repeat... until True" loop. But since Python
doesn't have syntax for such repeat until loops, our work-around is to
use a while True and break out of it at the end of the loop.
To be honest, I'm having trouble thinking of a good use-case for "while
True", now that we have infinite iterators. Most cases of
while True:
x = get_item()
if not x: break
process(x)
are better written as:
for x in iterator:
process(x)
--
Steve
--
https://mail.python.org/mailman/listinfo/python-list