pairs from a list
George Sakkis
george.sakkis at gmail.com
Mon Jan 21 23:54:28 EST 2008
On Jan 21, 10:20 pm, Alan Isaac <ais... at american.edu> wrote:
> I want to generate sequential pairs from a list.
> Here is a way::
>
> from itertools import izip, islice
> for x12 in izip(islice(x,0,None,2),islice(x,1,None,2)):
> print x12
>
> (Of course the print statement is just illustrative.)
> What is the fastest way? (Ignore the import time.)
Look up the timeit module and test yourself the various alternatives;
that's the most reliable way to tell for sure.
George
More information about the Python-list
mailing list