def chunk(elist, size):
 for i in xrange(0, len(elist), size):
  (yield elist[i:(i + size)])

def chunk ( elist , size ) : for i in xrange ( 0 , len ( elist ) , size ) : ( yield elist [ i : ( i + size ) ] )
yield chunks of an iterable .