Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support replacing range arguments with enumerate #13

Open
Tadaboody opened this issue Dec 2, 2018 · 0 comments
Open

Support replacing range arguments with enumerate #13

Tadaboody opened this issue Dec 2, 2018 · 0 comments

Comments

@Tadaboody
Copy link
Owner

An extension of #4
The function range(start,stop,step) can be replaced with enumerate(islice(iterable,start,stop,step)) or even just islice if the index isn't used out of the assign.
for example

for i in range(3,len(seq),2):
    x = seq[i]
    ...

can be replaced with

for x in islice(seq,start=3,stop=None,step=2):
    ...

or in the case of a sequence (and not just an iterator) even

for x in seq[3:-1:2]:
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant