bronx.compat.itertools

Compatibility for some of the features of the itertools modules.

The pairwise function was introduced with Python3.10, we provide here a close approximation. The real thing is used from 3.10 and on.

Functions

bronx.compat.itertools.pairwise(iterable)[source]

Return successive overlapping pairs taken from the input iterable.

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