def chunk_list(ls, items=8):
 itms = []
 for (i, v) in enumerate(ls):
  if ((i >= items) and ((i % items) == 0)):
   (yield itms)
   itms = [v]
  else:
   itms.append(v)
 if itms:
  (yield itms)

def chunk_list ( ls , items = 8 ) : itms = [ ] for ( i , v ) in enumerate ( ls ) : if ( ( i >= items ) and ( ( i % items ) == 0 ) ) : ( yield itms ) itms = [ v ] else : itms . append ( v ) if itms : ( yield itms )
iterate through chunks of a list .