Skip to content

[3.13] Docs: Improve example for itertools.batched() (GH-136775) #136779

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

Merged
merged 1 commit into from
Jul 19, 2025

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 38643099+RafaelWO@users.noreply.github.com


📚 Documentation preview 📚: https://cpython-previews--136779.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 <38643099+RafaelWO@users.noreply.github.com>
@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 96fac51 into python:3.13 Jul 19, 2025
30 of 31 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jul 19, 2025
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