def ichunk(iterable, n):
  """ Split an iterable into n-sized chunks. """
  it = iter(iterable)
  while True:
    chunk = tuple(itertools.islice(it, n))
    if not chunk:
      return
    yield chunk
def ichunk ( iterable , n ) : it = iter ( iterable ) while True : chunk = tuple ( itertools . islice ( it , n ) ) if not chunk : return yield chunk
Split an iterable into n-sized chunks.