Why chunks is not part of the python standard lib?

Paul Rubin no.email at nospam.invalid
Wed May 1 12:30:19 EDT 2013


Serhiy Storchaka <storchaka at gmail.com> writes:
> def chunks(seq, size):
>     return [seq[i: i + size] for i in range(0, len(seq), size)]

That's just for lists.  An itertools version would work with arbitrary
iterables.  I've also had to rewrite that function more times than seems
proper.



More information about the Python-list mailing list