Has anyone considered the idea of adding a "do at least once" loop to Python?
This is frequently referred to as a do ... while or repeat ... until.
At the moment, it's a bit of a hack to achieve this in that we do a 'while
True: ( do thing ; if cond: ( break ) )'. Since I don't know how to format
these messages, I've used '{' for line-beak-and-indent, ')' for
line-break-and-dedent, and ';' for line-break-keeping-same-indent-level.
My initial thoughts are that it would be reasonably easy to add a 'repeat: ( do
thing ) until condition' which would far better specify intent of the loop
(despite the possibility of break, while-true loops give no indication that
it's not an infinite loop.
And using repeat...until will ensure whoever had to add the code to the Python
interpreter wouldn't have any clashes with the current while loop.
Thoughts, anyone? Anyone? Bueller? :-)
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2PM6QEZJAPE3H72GA6TJJIWNBT3Y3WLN/
Code of Conduct: http://python.org/psf/codeofconduct/