Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Docs: Improve example foritertools.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Docs: Improve example foritertools.batched()
#136775
Conversation
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`
python-cla-botbot commentedJul 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@AA-Turner, thanks for the review! 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you!
A
itertools.batched
itertools.batched()
3eecc72
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@RafaelWO for the PR, and@AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
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 3eecc72ac70943f7e33297eea17803af15322c88)Co-authored-by: RafaelWO <38643099+RafaelWO@users.noreply.github.com>
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 commit3eecc72)Co-authored-by: RafaelWO <38643099+RafaelWO@users.noreply.github.com>
GH-136778 is a backport of this pull request to the3.14 branch. |
GH-136779 is a backport of this pull request to the3.13 branch. |
…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 commit3eecc72)Co-authored-by: RafaelWO <38643099+RafaelWO@users.noreply.github.com>
…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 commit3eecc72)Co-authored-by: RafaelWO <38643099+RafaelWO@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
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 then
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/