[Python-ideas] itertools.chunks()
Giampaolo Rodolà
g.rodola at gmail.com
Sat Apr 6 20:53:37 CEST 2013
2013/4/6 João Bernardo <jbvsmo at gmail.com>:
> Isn't it just
>
> divmod(total, step)
>
> João Bernardo
Not really:
>>> list(chunks(13, 4))
[4, 4, 4, 1]
>>> divmod(13, 4)
(3, 1)
Literally chunks() keeps yielding 'step' until 'total' is reached and
makes sure the last yielded item has the correct remainder.
--- Giampaolo
https://code.google.com/p/pyftpdlib/
https://code.google.com/p/psutil/
https://code.google.com/p/pysendfile/
More information about the Python-ideas
mailing list