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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-118476: update the example implementation for islice in docs #118466

Closed
wants to merge 4 commits into from

Conversation

FHTMitchell
Copy link

@FHTMitchell FHTMitchell commented May 1, 2024

  • The previous version was needlessly complicated
  • It was also wrong since it overwrote stop == 0 to maxsize so
list(islice([1,2,3], 0))

looked like it returned [1,2,3] rather than [].

Fixes #118476


馃摎 Documentation preview 馃摎: https://cpython-previews--118466.org.readthedocs.build/

* The previous version was needlessly complicated
* It was also wrong since it overwrote stop == 0 to maxsize
Copy link

cpython-cla-bot bot commented May 1, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels May 1, 2024
@FHTMitchell FHTMitchell changed the title Trivial: update the example implementation for islice in docs gh-118476: update the example implementation for islice in docs May 1, 2024
@rhettinger rhettinger self-assigned this May 3, 2024
Comment on lines +516 to +517
for i, element in enumerate(it, start):
if (i - start) % step == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding this comment here?

Suggested change
for i, element in enumerate(it, start):
if (i - start) % step == 0:
for i, element in enumerate(it, start):
# Consume to *stop*.
if (i - start) % step == 0:

@rhettinger
Copy link
Contributor

Closing this because a much improved version was found by Stefan Pochmann.

@rhettinger rhettinger closed this May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect and overly-complicated islice example implementation in docs
3 participants