simple question re list iteration semantics
Esmail
ebonak at hotmail.com
Tue Apr 21 21:06:46 EDT 2009
Hello all,
I have a simple question regarding semantics.
Given a list 'li', I can always do this to iterate through all items in
order:
for i in range(0, len(li)):
print li[i]
Will this always be equivalent to
for i in li:
print i
I assume it is, and the order will always be the same, or am I mistaken?
Would the 2nd one be considered more Pythonic? (It looks both
clearer and cleaner to me).
Thanks.
Esmail
More information about the Python-list
mailing list