def sliding_window(seq, n=<NUM_LIT:2>):
it = iter(seq)<EOL>result = tuple(itertools.islice(it, n))<EOL>if len(result) == n:<EOL><INDENT>yield result<EOL><DEDENT>for elem in it:<EOL><INDENT>result = result[<NUM_LIT:1>:] + (elem,)<EOL>yield result<EOL><DEDENT>
Generate overlapping sliding/rolling windows (of width n) over an iterable

    s -> (s0,s1,...s[n-1]), (s1,s2,...,sn), ...

    References:
      http://stackoverflow.com/a/6822773/623735

    Examples:

    >>> list(sliding_window(range(6), 3))  # doctest: +NORMALIZE_WHITESPACE
    [(0, 1, 2),
     (1, 2, 3),
     (2, 3, 4),
     (3, 4, 5)]