On Tue, May 2, 2017 at 8:10 AM <[email protected]> wrote: > Steven D’Aprano was giving me an idea (in the bytes.hex delimiter > discussion): > > > > I had very often the use case that I want to split sequences into > subsequences of same size. > > 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]] > > "1234“.chunks(2) => [“12“, “34“] > > > > (this could then be used to emulate stevens proposal: “ > “.join(“1234567“.chunks(2)) => “12 34 56 7“) > > >
Changing the definition of the Sequence ABC to avoid needing to use a 2-line function from the itertools recipes seems like a pretty drastic change. I don't think there's even a compelling argument for adding grouper() to itertools, let along to every single sequence.
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
