-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.12only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement
Description
This was requested on python-ideas:
def batched(iterable, n):
"Batch data into lists of length n. The last batch may be shorter."
# batched('ABCDEFG', 3) --> ABC DEF G
if n < 1:
raise ValueError('n must be >= 1')
it = iter(iterable)
while (batch := list(islice(it, n))):
yield batch
Linked PRs
rishi93, seblin, mahdithejedi, AlexWaygood, amirsoroush and 6 moreRickardCardell, OvervCW, cjrh, jstriebel, f2koi and 3 more
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement