pairwise

pairwise(iterable)[source]

A sequence of overlapping sub-sequences.

Parameters

iterable (iterable) – An iterable object.

Returns

A zip object.

Return type

zip

Example:

>>> list(pairwise([1, 2, 3, 4, 5]))
[(1, 2), (2, 3), (3, 4), (4, 5)]