[Python-ideas] [Python-Dev] itertools.chunks(iterable, size, fill=None)

Raymond Hettinger raymond.hettinger at gmail.com
Tue Jul 3 06:23:29 CEST 2012


On Jul 1, 2012, at 5:01 AM, Stefan Behnel wrote:

> To address the main problem of users not finding what they need, what about
> simply extending the docstring of the grouper()


Here's  a small change to the docstring:  http://hg.python.org/cpython/rev/d32f21d87363

FWIW, if you're interested in load balancing applications, George Sakkis's itertools 
recipe for roundrobin() may be of interest.

Another interesting iterator technique that is not well known is the two-argument 
form of iter() which is a marvel for transforming callables into iterators:

    for block in iter(partial(f.read, 1024), ''):
           ...

    for diceroll in iter(partial(randrange(1, 7), 4):
           ...


Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120702/8550f12c/attachment.html>


More information about the Python-ideas mailing list