[TriZPUG] iterate over a list in bunches

Chris Rossi chris at archimedeanco.com
Thu Aug 11 22:44:27 CEST 2011


On Thu, Aug 11, 2011 at 4:40 PM, Nathan Rice <
nathan.alexander.rice at gmail.com> wrote:

> I'm also partial to izip_longest.  I think I'd probably go with
> something along the lines of:
>
> def __iter__(self):
>    columns = (item[start::row_size] for start in range(row_size))
>    for group in itertools.izip_longest(*columns, fill=whatever):
>         yield group
>
>
Nice.

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/trizpug/attachments/20110811/1420c7b5/attachment.html>


More information about the TriZPUG mailing list