An endless loop

Ned Batchelder ned at nedbatchelder.com
Sun Oct 15 10:38:13 EDT 2017


On 10/15/17 9:59 AM, bartc wrote:
> On 15/10/2017 12:20, Chris Angelico wrote:
>> On Sun, Oct 15, 2017 at 9:15 PM, bartc <bc at freeuk.com> wrote:
>
>>> I assume you're talking about the while-loop (because on my machine, it
>>> hangs just using 'from turtle...' or 'import turtle').
>
> (Machine was screwed up I think, as I had to restart it shortly after 
> for other reasons. When the turtle graphics worked.)
>
>>> That looks to be a repeat-N-times loop. There isn't a dedicated 
>>> statement
>>> for that, the closest Python feature would be 'for i in range(n)' 
>>> with i a
>>> dummy loop variable.
>>
>> You can use that or "for _ in range(n)" as a pretty effective form of
>> that loop. I've never had a problem with it. Python doesn't need
>> another type of loop.
>
> I could understand that sentiment if there were already dozens. But I 
> believe there's only, what, two loop types? To implement a number of 
> basic looping requirements which, if not that numerous, are somewhat 
> more than two.
>
> Not exactly taxing the grey matter which already has those extra loop 
> types in mind, and has to find a way to express them in terms of only 
> two.
>

We've covered this before.  A challenge for the group: let's not create 
yet another 100-reply thread rehashing the design of Python looping... 
Please? :)

--Ned.




More information about the Python-list mailing list