How do I process the elements of a sequence in batches, idiomatically?
For example, with the sequence \"abcdef\" and a batch size of 2, I would like to do something
From the docs of more_itertools: more_itertools.chunked()
more_itertools.chunked(iterable, n)
Break an iterable into lists of a given length:
>>> list(chunked([1, 2, 3, 4, 5, 6, 7], 3))
[[1, 2, 3], [4, 5, 6], [7]]
If the length of iterable is not evenly divisible by n, the last returned list will be shorter.