grr/core/grr_response_core/lib/util/collection.py
def Batch(items, size):
  """Divide items into batches of specified size.

  In case where number of items is not evenly divisible by the batch size, the
  last batch is going to be shorter.

  Args:
    items: An iterable or an iterator of items.
    size: A size of the returned batches.

  Yields:
    Lists of items with specified size.
  """
  batch = []

  for item in items:
    batch.append(item)
    if len(batch) == size:
      yield batch
      batch = []

  if batch:
    yield batch
Divide items into batches of specified size.

  In case where number of items is not evenly divisible by the batch size, the
  last batch is going to be shorter.

  Args:
    items: An iterable or an iterator of items.
    size: A size of the returned batches.

  Yields:
    Lists of items with specified size.
  
Divide items into batches of specified size.
In case where number of items is not evenly divisible by the batch size, the
last batch is going to be shorter.
Divide items into batches of specified size . In case where number of items is not evenly divisible by the batch size the last batch is going to be shorter .
def Batch(items, size):
  batch = []
  for item in items:
    batch.append(item)
    if len(batch) == size:
      yield batch
      batch = []
  if batch:
    yield batch
def Batch ( items , size ) : batch = [ ] for item in items : batch . append ( item ) if len ( batch ) == size : yield batch batch = [ ] if batch : yield batch
Divide items into batches of specified size.
Divide items into batches of specified size .
"""Divide items into batches of specified size.

  In case where number of items is not evenly divisible by the batch size, the
  last batch is going to be shorter.

  Args:
    items: An iterable or an iterator of items.
    size: A size of the returned batches.

  Yields:
    Lists of items with specified size.
  """
Lists of items with specified size.
Lists of items with specified size .
items
An iterable or an iterator of items.
An iterable or an iterator of items .
size
A size of the returned batches.
A size of the returned batches .