Skip to content

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
@FHTMitchell FHTMitchell requested a review from rhettinger as a code owner May 1, 2024 10:02
@ghost
Copy link

ghost 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