def Grouper(iterable, n):
 items = []
 for (count, item) in enumerate(iterable):
  items.append(item)
  if (((count + 1) % n) == 0):
   (yield items)
   items = []
 if items:
  (yield items)

def Grouper ( iterable , n ) : items = [ ] for ( count , item ) in enumerate ( iterable ) : items . append ( item ) if ( ( ( count + 1 ) % n ) == 0 ) : ( yield items ) items = [ ] if items : ( yield items )
group iterable into lists of size n .