jaraco/itertools.py
def balanced_rows(n, iterable, fillvalue=None):
	"""
	Like grouper, but balance the rows to minimize fill per row.
	balanced_rows(3, 'ABCDEFG', 'x') --> ABC DEx FGx"
	"""
	iterable, iterable_copy = itertools.tee(iterable)
	count = len(tuple(iterable_copy))
	for allocation in partition_items(count, n):
		row = itertools.islice(iterable, allocation)
		if allocation < n:
			row = itertools.chain(row, [fillvalue])
		yield tuple(row)
def balanced_rows(n, iterable, fillvalue=None):
	"""
	Like grouper, but balance the rows to minimize fill per row.
	balanced_rows(3, 'ABCDEFG', 'x') --> ABC DEx FGx"
	"""
	iterable, iterable_copy = itertools.tee(iterable)
	count = len(tuple(iterable_copy))
	for allocation in partition_items(count, n):
		row = itertools.islice(iterable, allocation)
		if allocation < n:
			row = itertools.chain(row, [fillvalue])
		yield tuple(row)
def balanced_rows ( n , iterable , fillvalue = None ) : iterable , iterable_copy = itertools . tee ( iterable ) count = len ( tuple ( iterable_copy ) ) for allocation in partition_items ( count , n ) : row = itertools . islice ( iterable , allocation ) if allocation < n : row = itertools . chain ( row , [ fillvalue ] ) yield tuple ( row )
Like grouper, but balance the rows to minimize fill per row.
	balanced_rows(3, 'ABCDEFG', 'x') --> ABC DEx FGx"
Like grouper but balance the rows to minimize fill per row . balanced_rows ( 3 ABCDEFG x ) -- > ABC DEx FGx