Looping [was Re: Python and the need for speed]
Marko Rauhamaa
marko at pacujo.net
Mon Apr 17 03:11:40 EDT 2017
Gregory Ewing <greg.ewing at canterbury.ac.nz>:
> bartc wrote:
>> Most of my loops start off as endless loops, until I can determine
>> the actual terminating condition, and where it best goes.
>
> Interesting. My experience is quite different. Most of the loops I
> write start off with me thinking "Now I want to do this for each
> element of this collection", which maps straight to a Python for-loop.
>
> In the rare cases where I do use a while loop, usually I have a fairly
> good idea what the terminating condition is going to be.
Here's statistics from a medium-sized project of mine:
while True: 34
while <condition>: 39
for ... in ...: 158
Marko
More information about the Python-list
mailing list