Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
samdk
on April 25, 2012
|
parent
|
context
|
favorite
| on:
Python iteration
I use it rarely in Python, although it's sometimes useful. I use it more often in other languages to replicate Python's enumerate, since zip(range(len(seq)),seq) is basically enumerate(seq) (although with this implementation it's not a generator).
koenigdavidmj
on April 25, 2012
[–]
Ah, but this is:
from itertools import izip izip(xrange(len(seq)), seq)
kbd
on April 25, 2012
|
parent
[–]
And in Python 3 it's a generator with
zip(range(len(seq)), seq)
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: