def pairwise(iterable):
    """Pair each element with its neighbors.

    Arguments
    ---------
    iterable : iterable

    Returns
    -------
    The generator produces a tuple containing a pairing of each element with
    its neighbor.
    """
    iterable = iter(iterable)
    left = next(iterable)
    for right in iterable:
        yield left, right
        left = right