Consider making enumerate a sequence if its argument is a sequence

30 Sep
2015
30 Sep
'15
5:28 p.m.
What are the pros and cons of making enumerate a sequence if its argument is a sequence?
I found myself writing:
for vertex, height in zip( self.cache.height_to_vertex[height_slice], range(height_slice.start, height_slice.stop)):
I would have preferred:
for height, vertex in enumerate( self.cache.height_to_vertex)[height_slice]:

30 Sep
30 Sep
6:36 p.m.
New subject: Consider making enumerate a sequence if its argument is a sequence
On 30.09.15 18:28, Neil Girdhar wrote:
What are the pros and cons of making enumerate a sequence if its argument is a sequence?
I found myself writing:
for vertex, height in zip( self.cache.height_to_vertex[height_slice], range(height_slice.start, height_slice.stop)):
I would have preferred:
for height, vertex in enumerate( self.cache.height_to_vertex)[height_slice]:
You can write:
for height, vertex in enumerate( self.cache.height_to_vertex[height_slice], height_slice.start):
2728
Age (days ago)
2728
Last active (days ago)
1 comments
2 participants
participants (2)
-
Neil Girdhar
-
Serhiy Storchaka