import itertools


def pairwise(iterable):
    """
    Takes an Iterable and returns an iterable of tuples that pair each of the elements
    with its respective successor.
    pairwise(range(5)) becomes [(0, 1), (1, 2), (2, 3), (3, 4)]
    """
    t1, t2 = itertools.tee(iterable, 2)
    next(t2)
    return zip(t1, t2)