<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">Further more I explained why I think iteration over index should be the </span><br style="font-size:12.8px"><span style="font-size:12.8px">preferred way, it help with readability a lot.</span></blockquote><div><br>I think you'll find this statement at odds with most of the Python community, especially Guido. I find looping over objects in a collection is what you want to do 90% of the time so adding an extra step just adds noise.<br><br>I find that most people who prefer looping over indexes do so because they are more familiar with languages like C, not because it is inherently more readable. Being more comfortable with a worse way of doing something isn't a good justification for changing the language.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 11:31 AM, Mikhail V <span dir="ltr"><<a href="mailto:mikhailwas@gmail.com" target="_blank">mikhailwas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 17 February 2017 at 17:37, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, Feb 18, 2017 at 3:30 AM, Mikhail V <<a href="mailto:mikhailwas@gmail.com" target="_blank">mikhailwas@gmail.com</a>> wrote:<br>
> On 17 February 2017 at 04:59, Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> wrote:<br>
>><br>
>> On Fri, Feb 17, 2017 at 2:13 PM, Mikhail V <<a href="mailto:mikhailwas@gmail.com" target="_blank">mikhailwas@gmail.com</a>> wrote:<br>
>> > Common use case:<br>
>> ><br>
>> > L = [1,3,5,7]<br>
>> ><br>
>> > for i over len(L):<br>
>> > e = L[i]<br>
>> ><br>
>> > or:<br>
>> ><br>
>> > length = len(L)<br>
>> > for i over length:<br>
>> > e = L[i]<br>
>><br>
>> Better use case:<br>
>><br>
>> for i, e in enumerate(L):<br>
>><br>
><br>
> This would be more compact, yet less readable, more error prone variant.<br>
> I'd avoid it it all costs and even if I don't need the index further in loop<br>
> body,<br>
> (which happens rarely in my experience) I write e=L[i] in second line<br>
> to make the code more verbose and keep the flow order.<br>
> So your variant (and those proposed in PEP-212) could serve in list<br>
> comprehensions for example, but for common 'expanded' code I find it<br>
> decline of readability, and creating totally different variants for same<br>
> iteration idea.<br>
> But partially that could be simply matter of habit and love to contractions.<br>
<br>
If you don't need the index, why not just iterate over the list directly?<br>
<br>
for e in L:<br>
<br>
That's the single most obvious way to step through a collection in<br>
Python. What do you need to count up to the length for?<br>
<br>
</blockquote></div><br></div></div></div><div class="gmail_extra">I have said I need the index, probably you've misread my last comment.<br>Further more I explained why I think iteration over index should be the <br>preferred way, it help with readability a lot.<br></div><div class="gmail_extra">All my learning years ended up with rewriting most code to "for i in range()"<br></div><div class="gmail_extra">and I slap myself when I start to write "for e in L". <br></div><div class="gmail_extra">It is exactly where TOOWTDI applies perfectly and it is integer iteration for me.<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra"><br></div><div class="gmail_extra">Mikhail<br></div></font></span></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br></blockquote></div><br></div>