You can always use a counter if you don't like our fancy for-each loops;<br><br>foolist = [1,24,24,234,23,423,4]<br>for i in xrange(len(foolist)):<br>    print foolist[i]<br><br><div class="gmail_quote">On Mon, Sep 24, 2012 at 9:29 AM, Tim Chase <span dir="ltr"><<a href="mailto:python.list@tim.thechases.com" target="_blank">python.list@tim.thechases.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 09/23/12 17:54, Steven D'Aprano wrote:<br>
> On Sun, 23 Sep 2012 10:45:53 -0700, jimbo1qaz wrote:<br>
>> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:<br>
>>> Am I missing something obvious, or do I have to manually put in a<br>
>>> counter in the for loops? That's a very basic request, but I couldn't<br>
>>> find anything in the documentation.<br>
>><br>
>> Ya, they should really give a better way, but for now, enumerate works<br>
>> pretty well.<br>
><br>
> Define "a better way". What did you have in mind that would work better?<br>
<br>
</div>I can only imagine jimbo1qaz intended "a more C-like way".  blech.<br>
<br>
I **far** prefer The Python Way™.  The vast majority of the time,<br>
I'm looping over some iterable where indices would only get in the<br>
way of readability.  Tuple-unpacking the results of enumerate() is<br>
an elegant way of getting both the items+indices on the seldom<br>
occasion I need the index too (though I'm minorly miffed that<br>
enumerate()'s starting-offset wasn't back-ported into earlier 2.x<br>
versions and have had to code around it for 1-based indexing; either<br>
extra "+1"s or whip up my own simple enumerate() generator).<br>
<br>
-tkc<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>