diff --git a/pixelocr/utils.py b/pixelocr/utils.py index c1fc320..df3d9a4 100644 --- a/pixelocr/utils.py +++ b/pixelocr/utils.py @@ -15,6 +15,8 @@ import functools +import itertools + def cached_property(fun): """A memoize decorator for class properties.""" @@ -36,3 +38,9 @@ def collect_iterable(func): def collect(*args, **kwargs): return list(func(*args, **kwargs)) return collect + + +def pairwise(iterable): + a, b = itertools.tee(iterable) + next(b, None) + return itertools.zip_longest(a, b)