def pairwise ( iterable ) : first , second = tee ( iterable ) next ( second , None ) return zip ( first , second )
python itertools tuple for every two elements
From itertools cookbook . [ a b c ... ] - > ( a b ) ( b c ) ...
def pairwise(iterable):
    """From itertools cookbook. [a, b, c, ...] -> (a, b), (b, c), ..."""
    first, second = tee(iterable)
    next(second, None)
    return zip(first, second)