[ python-Feature Requests-892804 ] Enumerate with step

SourceForge.net noreply at sourceforge.net
Sun Feb 8 06:16:57 EST 2004


Feature Requests item #892804, was opened at 2004-02-08 06:02
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=892804&group_id=5470

Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Gerrit Holl (gerrit)
Assigned to: Nobody/Anonymous (nobody)
Summary: Enumerate with step

Initial Comment:
I tried to do:

enumerate(letters)[::3]

...when I found out it didn't work. And it's different
from:

enumerate(letters[::3])

It would be nice if enumerate had a 'step' argument by
default, without subclassing it by hand.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-02-08 06:16

Message:
Logged In: YES 
user_id=80475

Guido rejected the step argument to keep it separate from
slicing.

For a workaround, use itertools.islice():
    islice(enumerate('hello'),0,None,3)



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=892804&group_id=5470



More information about the Python-bugs-list mailing list