[New-bugs-announce] [issue1502] itertools should grow chunkify

Chris Mellon report at bugs.python.org
Tue Nov 27 00:42:24 CET 2007

New submission from Chris Mellon:

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.

components: Library (Lib)
files: chunkify.patch
messages: 57861
nosy: arkanes
severity: normal
status: open
title: itertools should grow chunkify
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file8811/chunkify.patch

Tracker <report at bugs.python.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chunkify.patch
Type: application/octet-stream
Size: 8257 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20071126/c50f5f4a/attachment.obj 

More information about the New-bugs-announce mailing list