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 <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1502>
__________________________________

Attachment: chunkify.patch
Description: Binary data

_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to