jord.shapely_utilities.iteration.pairs#

jord.shapely_utilities.iteration.pairs(s: Sequence) Tuple[Any, Any][source]#

Iterate over a list in overlapping pairs.

Usage:

lst = [4, 7, 11, 2] pairs(lst) yields (4, 7), (7, 11), (11, 2)

http://stackoverflow.com/questions/1257413/1257446#1257446

Parameters:

s – an iterable/list

Returns:

Yields a pair of consecutive elements (lst[k], lst[k+1]) of lst. Last call yields (lst[-2], lst[-1]).