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

Todd toddrjen at gmail.com
Mon Jun 26 09:15:43 EDT 2017


On Jun 26, 2017 2:15 AM, "Chris Angelico" <rosuav at gmail.com> wrote:

On Mon, Jun 26, 2017 at 4:08 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>> If we wanted to allow that to be expressed literally, we could
>> probably special case the "while not break" keyword sequence as a do
>> loop:
>>
>>      while not break:
>>          # Setup
>>          if condition: break
>>          # Loop continuation
>
>
> We would then also need 'while not return:'

And for completeness, "while not throw:"


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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170626/8371171d/attachment.html>


More information about the Python-ideas mailing list