itertools.count() as built-in
jantod at gmail.com
jantod at gmail.com
Mon May 29 04:41:57 EDT 2006
Oops. The messed-up version wasn't supposed to be messed-up. Two
mistakes on one line. Which kinda proves my point :)
I'd much rather use the count version than (1) or (2). (1) has the
problem of having "incorrect" values the rest of the time in the loop
and (2) is going to an extreme just to avoid an import of count.
Your zipwithcount doesn't look as obvious as
for n, a, b in zip(count(), A, B)
but is still easier to read than
for n, (a, b) in enumerate(zip(A, B))
-Janto
More information about the Python-list
mailing list