The "loop and a half"
bartc
bc at freeuk.com
Wed Oct 4 09:14:38 EDT 2017
On 04/10/2017 14:02, Robin Becker wrote:
> On 04/10/2017 11:57, Rhodri James wrote:
>> On 04/10/17 10:01, Robin Becker wrote:
>>> Given the prevalence of the loop and a half idea in python I wonder
>>> why we don't have a "do" or "loop" statement to start loops without a
>>> test.
>>
>> See PEP 315. Guido's rejection note is here:
>> https://mail.python.org/pipermail/python-ideas/2013-June/021610.html
>>
> seems fair enough; I suppose the cost is negligible or perhaps there's
> peephole optimization for this common case.
Read the thread. Not having a dedicated feature means I counted at least
half a dozen different ideas for implementing what the OP really wanted
to do, which was expressed using C-like syntax. None of which were as
obvious.
And that C-like one worked because it could use an assignment within a
while-condition.
--
bartc
More information about the Python-list
mailing list