Message188378
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).) |
|
Date |
User |
Action |
Args |
2013-05-04 17:15:40 | ezio.melotti | set | recipients:
+ ezio.melotti, rhettinger, terry.reedy, techtonik |
2013-05-04 17:15:40 | ezio.melotti | set | messageid: <1367687740.68.0.302432676092.issue17862@psf.upfronthosting.co.za> |
2013-05-04 17:15:40 | ezio.melotti | link | issue17862 messages |
2013-05-04 17:15:40 | ezio.melotti | create | |
|