-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
GH-98363: Add itertools.batched() #98364
Conversation
rhettinger
commented
Oct 17, 2022
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: Add itertools.batched() #98363
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.
I agree with adding this, just a few small comments.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
🤖 New build scheduled with the buildbot fleet by @rhettinger for commit b9cbb46 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Roughly equivalent to:: | ||
|
||
def batched(iterable, n): | ||
# batched('ABCDEFG', 3) --> ABC DEF G |
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.
Maybe tweak the example so it cannot be misunderstood as "return 3 batches"?
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.
# batched('ABCDEFG', 3) --> ABC DEF G | |
# list(batched('ABCDEFG', 3)) --> [['A', 'B', 'C'], ['D', 'E', 'F'], ['G']] |