> How about adding a chunks() and rchunks() function to sequences:
>
> [1,2,3,4,5,6,7].chunks(3) => [[1,2,3], [4,5,6], [7]]

I prefer str.join() approach: write a single chunks() function which
takes a sequence, instead of modifying all sequence types around the
world ;-)

It's less natural to write chunks(seq, n), but it's much simpler to
implement and will work on all Python versions, enjoy!

Victor
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to