[Python-ideas] More classical for-loop

Sven R. Kunze srkunze at mail.de
Fri Feb 17 04:31:29 EST 2017


On 17.02.2017 04:59, Chris Angelico wrote:
> On Fri, Feb 17, 2017 at 2:13 PM, Mikhail V <mikhailwas at gmail.com> wrote:
>> Common use case:
>>
>> L = [1,3,5,7]
>>
>> for i over len(L):
>>     e = L[i]
>>
>> or:
>>
>> length = len(L)
>> for i over length:
>>     e = L[i]
> Better use case:
>
> for i, e in enumerate(L):

I totally agree with Chris here.

For me, there's no need for another for loop syntax. It would be better 
to learn Python idioms instead.

Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170217/600155c9/attachment.html>


More information about the Python-ideas mailing list