import itertools


def pairwise(iterable):
    """
    Iterate pairwise through an iterable.

    pairwise([1,2,3,4]) -> (1,2),(2,3),(3,4)
    """
    val, nextVal = itertools.tee(iterable)
    next(nextVal, None)
    return zip(val, nextVal)