code: def partition_all(n, iterable):
      
      it = iter(iterable)
      while True:
          chunk = list(itertools.islice(it, n))
          if not chunk:
              break
          yield chunk
docs: Partition a list into equally sized pieces, including last smaller parts
      http://stackoverflow.com/questions/5129102/python-equivalent-to-clojures-partition-all