code: def nwise(iterable, n):
      
      iters = itertools.tee(iterable, n)
      iters = (itertools.islice(it, i, None) for i, it in enumerate(iters))
      return itertools.izip(*iters)
docs: Iterate through a sequence with a defined length window
  
      >>> list(nwise(range(8), 3))
      [(0, 1, 2), (1, 2, 3), (2, 3, 4), (3, 4, 5), (5, 6, 7)]
  
      >>> list(nwise(range(3), 5))
      []
  
  
      Parameters
      ----------
      iterable
      n : length of each sequence
  
      Yields
      ------
      Tuples of length n