This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients ezio.melotti, rhettinger, techtonik, terry.reedy
Date 2013-05-04.17:15:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1367687740.68.0.302432676092.issue17862@psf.upfronthosting.co.za>
In-reply-to
Content
FWIW I'm +1 about adding grouper(), since it happened to me to use it and suggest more often than any other recipe (I think it's the only recipe I used/know), and even more often than some of the current itertools.
The fact that has been requested several times already it's a good indication that it's something useful, and not a feature creep (I don't think any other recipe received nearly as many requests).

Regarding use cases, a few days ago I needed it while shuffling a sequence of 20 chars and then split it in four 5-chars long groups.
I also remember writing code like this more than once:
>>> s = 'aaaaabbbbbcccccddddd'
>>> n = 5
>>> [s[x:x+n] for x in range(0,len(s),n)]
['aaaaa', 'bbbbb', 'ccccc', 'ddddd']

(As a side note, I find the grouper(iterable, n, fill) signature more intuitive than grouper(n, iterable, fill) (the recipe uses the latter).)
History
Date User Action Args
2013-05-04 17:15:40ezio.melottisetrecipients: + ezio.melotti, rhettinger, terry.reedy, techtonik
2013-05-04 17:15:40ezio.melottisetmessageid: <1367687740.68.0.302432676092.issue17862@psf.upfronthosting.co.za>
2013-05-04 17:15:40ezio.melottilinkissue17862 messages
2013-05-04 17:15:40ezio.melotticreate