-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Docs: Improve example for itertools.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`
@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()
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 3eecc72) 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 commit 3eecc72) Co-authored-by: RafaelWO <38643099+RafaelWO@users.noreply.github.com>
GH-136778 is a backport of this pull request to the 3.14 branch. |
GH-136779 is a backport of this pull request to the 3.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 commit 3eecc72) 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 commit 3eecc72) 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 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/