Skip to content

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

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--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 <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 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
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy