Skip to content

Docs: Improve example for itertools.batched() #136775

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

Conversation

RafaelWO
Copy link
Contributor

@RafaelWO RafaelWO 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


📚 Documentation preview 📚: https://cpython-previews--136775.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`
@RafaelWO RafaelWO requested a review from rhettinger as a code owner July 19, 2025 08:57
@python-cla-bot
Copy link

python-cla-bot bot commented Jul 19, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@RafaelWO
Copy link
Contributor Author

@AA-Turner, thanks for the review! 🙂

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

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

Thank you!

A

@AA-Turner AA-Turner changed the title Docs: Improve example of itertools.batched Docs: Improve example for itertools.batched() Jul 19, 2025
@AA-Turner AA-Turner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jul 19, 2025
@AA-Turner AA-Turner merged commit 3eecc72 into python:main Jul 19, 2025
43 checks passed
@miss-islington-app
Copy link

Thanks @RafaelWO for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jul 19, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request 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>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request 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>
@bedevere-app
Copy link

bedevere-app bot commented Jul 19, 2025

GH-136778 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jul 19, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jul 19, 2025

GH-136779 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jul 19, 2025
AA-Turner pushed a commit that referenced this pull request Jul 19, 2025
…136779)

Docs: Improve example for ``itertools.batched()`` (GH-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 <38643099+RafaelWO@users.noreply.github.com>
AA-Turner pushed a commit that referenced this pull request Jul 19, 2025
…136778)

Docs: Improve example for ``itertools.batched()`` (GH-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 <38643099+RafaelWO@users.noreply.github.com>
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 sprint
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