I have not seen this posted and I kind of like it. Shared for entertainment value only. Alan Isaac PS Easily adapted if the residual group is not desired. def groupsofsize(iterable,size): itr = iter(iterable) c=count() for k,it in groupby(itr,lambda x:c.next()//size): yield tuple(y for y in it)