generate tuples from sequence

Alan Isaac aisaac at american.edu
Thu Jan 18 04:53:14 CET 2007


"Peter Otten" <__peter__ at web.de> wrote in message
news:eol9ac$v3l$02$1 at news.t-online.com...
> I like
>
> >>> items = range(9)
> >>> N = 3
> >>> zip(*[iter(items)]*N)
> [(0, 1, 2), (3, 4, 5), (6, 7, 8)]

Except that it is considered implementation dependent:
http://mail.python.org/pipermail/python-list/2005-February/307550.html

Alan Isaac





More information about the Python-list mailing list