def pairwise(iterable, cyclic=False):
 (a, b) = tee(iterable)
 first = next(b, None)
 if (cyclic is True):
  return zip(a, chain(b, (first,)))
 return zip(a, b)

def pairwise ( iterable , cyclic = False ) : ( a , b ) = tee ( iterable ) first = next ( b , None ) if ( cyclic is True ) : return zip ( a , chain ( b , ( first , ) ) ) return zip ( a , b )
return the items of an iterable paired with its next item .