Author arkanes
Recipients arkanes
Date 2007-11-26.23:42:23
SpamBayes Score 0.0654754
Marked as misclassified No
Message-id <>
One of the most common requests in c.l.p and #python is a way to break
an iterable up into some particular size chunks. For example, "abcdef"
-> "ab", "cd", "ef". It's pretty easy to write one, but there are a few
subtleties to it (like if you want padding or partial results) and it's
so common that having it in the stdlib would be nice.

Attached is a patch which implements itertools.chunkify. It can
optionally discard, pad, or return any leftovers in the source iterable.
Tests and docstrings are included, but it needs to be documented in the
manual. One thing it does not do, but maybe it should, is guess what
type the yielded values should have based on the input sequence - it
always returns lists.

Patch is against trunk, r59186.
File name Uploaded
chunkify.patch arkanes, 2007-11-26.23:42:23
Date User Action Args
2007-11-26 23:42:25arkanessetspambayes_score: 0.0654754 -> 0.0654754
recipients: + arkanes
2007-11-26 23:42:24arkanessetspambayes_score: 0.0654754 -> 0.0654754
messageid: <>
2007-11-26 23:42:24arkaneslinkissue1502 messages
2007-11-26 23:42:23arkanescreate