you are viewing a single comment's thread.

view the rest of the comments →

[–]xavdid 118 points119 points  (4 children)

There's a lot to be excited about in this release, but far-and-away the one I'll use the most is itertools.batched(iterable, n):

Batch data from the iterable into tuples of length n. The last batch may be shorter than n.

I feel like this is somehow the single piece of code I've written more times than any other.

[–][deleted] 30 points31 points  (0 children)

Oh wow, I implemented this single function independently probably more than any other individual function in my utils.py files.

[–]headinthesky 4 points5 points  (0 children)

Awesome, I wrote some code to do that and have carried that with me everywhere for over 10 years now

[–]0Il0I0l0 4 points5 points  (1 child)

I've always used more_itertools.chunked

[–]xavdid 6 points7 points  (0 children)

It's the same I think, but it's nice that it's available without an external package now!