python-dev

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [Python-Dev] Proposal: new list function: pack Nick Coghlan Fri Mar 20 22:00:25 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:
http://code.activestate.com/recipes/439095/

And a different take on providing similar functionality here:
http://code.activestate.com/recipes/544296/

However, the idea of providing a general windowing function in itertools
has been considered in the past and emphatically rejected:
http://mail.python.org/pipermail/python-dev/2006-May/065305.html

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/alexiscircle%40gmail.com