Hacker News new | ask | show | jobs
by kilburn 3742 days ago
I totally agree with you on the core issue.

However, I would reject your `chunks` function in a code review and tell you to use `grouper` form the itertools recipes [1].

More generally,any time I've ended up with a long list comprehension, the answer has been to "check itertools and see how you would describe this ugly comprehension in those terms"

[1] https://docs.python.org/3/library/itertools.html#itertools-r...

1 comments

Grouper is a recipe, it's not part of itertools. It probably should be!
All of the recipes in the itertools documentation should pretty much be considered folklore imho. If you always use the 'zip((iterator,)n)' approach, people will recognize it and know immediately what you mean.