[Python-Dev] Proposal: new list function: pack

Nick Coghlan ncoghlan at gmail.com
Sat Mar 21 05:04:58 CET 2009

Hrvoje Niksic wrote:
> Looking at izip(*[iter(l)]*n), I tend to agree.

Note that the itertools recipes page in the docs includes the following:

def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)

There are a couple of other variants here:

And a different take on providing similar functionality here:

However, the idea of providing a general windowing function in itertools
has been considered in the past and emphatically rejected:


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list