<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, May 2, 2017 at 8:10 AM <<a href="mailto:robert.hoelzl@posteo.de">robert.hoelzl@posteo.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="DE" link="blue" vlink="#954F72"><div class="m_-45131983578283858WordSection1"><p class="MsoNormal">Steven D’Aprano was giving me an idea (in the bytes.hex delimiter discussion):</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I had very often the use case that I want to split sequences into subsequences of same size.</p><p class="MsoNormal">How about adding a chunks() and rchunks() function to sequences:</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">[1,2,3,4,5,6,7].chunks(3) => [[1,2,3], [4,5,6], [7]]</p><p class="MsoNormal">"1234“.chunks(2) => [“12“, “34“]</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">(this could then be used to emulate stevens proposal: “ “.join(“1234567“.chunks(2)) => “12 34 56 7“)</p><p class="MsoNormal"><u></u> </p></div></div></blockquote><div><br></div><div>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. </div></div></div>