[Python-ideas] A suggestion for a do...while loop

Mikhail V mikhailwas at gmail.com
Mon Jun 26 16:20:22 EDT 2017


>All these situations could be handled by making a "while:" with no
>condition act as "while True:"

>But they could also be handled by updating pep8 to make "while True:" the
>recommended infinite loop syntax and make linters smarter about this (if
>they aren't already).

There was a big related discussion on Python-list in April (subject "Looping" ).

IMHO the cleanest way to denote an infinite loop would be
the statement "loop:"
Without introducing new keyword I think the optimal would be just "while:"

I dont't like "while True:"  simply because it does not make enough
visual distinction with the "while condition:" statement.
E.g. I can have

while True:
...
while Blue:
....

Which adds some extra brain load. So if there was explicit "while:" or "loop:"
I would update for it globally in my projects.



Mikhail


More information about the Python-ideas mailing list