Skip to content

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 19, 2025

The current example batched('ABCDEFG', n=3) → ABC DEF G can confuse readers because both, the size of the tuples and the number of tuples are 3.
By using a batch size of n=2, it is clearer that the n argument refers to the size of the resulting tuples.
I.e. the new example is: batched('ABCDEFG', n=2) → AB CD EF G
(cherry picked from commit 3eecc72)

Co-authored-by: RafaelWO [email protected]


📚 Documentation preview 📚: https://cpython-previews--136778.org.readthedocs.build/

The current example `batched('ABCDEFG', n=3) → ABC DEF G` can confuse readers because both, the size of the tuples and the number of tuples are 3.
By using a batch size of n=2, it is clearer that the `n` argument refers to the size of the resulting tuples.
I.e. the new example is: `batched('ABCDEFG', n=2) → AB CD EF G`
(cherry picked from commit 3eecc72)

Co-authored-by: RafaelWO <[email protected]>
@python-cla-bot
Copy link

python-cla-bot bot commented Jul 19, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@AA-Turner AA-Turner enabled auto-merge (squash) July 19, 2025 09:30
@AA-Turner AA-Turner merged commit aeeacdb into python:3.14 Jul 19, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jul 19, 2025
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…6775) (python#136778)

Docs: Improve example for ``itertools.batched()`` (pythonGH-136775)

The current example `batched('ABCDEFG', n=3) → ABC DEF G` can confuse readers because both, the size of the tuples and the number of tuples are 3.
By using a batch size of n=2, it is clearer that the `n` argument refers to the size of the resulting tuples.
I.e. the new example is: `batched('ABCDEFG', n=2) → AB CD EF G`
(cherry picked from commit 3eecc72)

Co-authored-by: RafaelWO <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants