code: def chunked(iterable, n):
      
      # Doesn't seem to run into any number-of-args limits.
      for group in (list(g) for g in zip_longest(*[iter(iterable)] * n,
                                                 fillvalue=_marker)):
          if group[-1] is _marker:
              # If this is the last group, shuck off the padding:
              del group[group.index(_marker):]
          yield group
docs: Break an iterable into lists of a given length::
  
          >>> list(chunked([1, 2, 3, 4, 5, 6, 7], 3))
          [[1, 2, 3], [4, 5, 6], [7]]
  
      If the length of ``iterable`` is not evenly divisible by ``n``, the last
      returned list will be shorter.
  
      This is useful for splitting up a computation on a large number of keys
      into batches, to be pickled and sent off to worker processes. One example
      is operations on rows in MySQL, which does not implement server-side
      cursors properly and would otherwise load the entire dataset into RAM on
      the client.