jaraco/itertools.py
def make_rows(num_columns, seq):
	"""
	Make a sequence into rows of num_columns columns.

	>>> tuple(make_rows(2, [1, 2, 3, 4, 5]))
	((1, 4), (2, 5), (3, None))
	>>> tuple(make_rows(3, [1, 2, 3, 4, 5]))
	((1, 3, 5), (2, 4, None))
	"""
	# calculate the minimum number of rows necessary to fit the list in
	# num_columns Columns
	num_rows, partial = divmod(len(seq), num_columns)
	if partial:
		num_rows += 1
	# break the seq into num_columns of length num_rows
	try:
		result = more_itertools.grouper(seq, num_rows)
	except TypeError:
		# more_itertools before 6.x
		result = more_itertools.grouper(num_rows, seq)
	# result is now a list of columns... transpose it to return a list
	# of rows
	return zip(*result)
def make_rows(num_columns, seq):
	# calculate the minimum number of rows necessary to fit the list in
	# num_columns Columns
	num_rows, partial = divmod(len(seq), num_columns)
	if partial:
		num_rows += 1
	# break the seq into num_columns of length num_rows
	try:
		result = more_itertools.grouper(seq, num_rows)
	except TypeError:
		# more_itertools before 6.x
		result = more_itertools.grouper(num_rows, seq)
	# result is now a list of columns... transpose it to return a list
	# of rows
	return zip(*result)
def make_rows ( num_columns , seq ) : # calculate the minimum number of rows necessary to fit the list in # num_columns Columns num_rows , partial = divmod ( len ( seq ) , num_columns ) if partial : num_rows += 1 # break the seq into num_columns of length num_rows try : result = more_itertools . grouper ( seq , num_rows ) except TypeError : # more_itertools before 6.x result = more_itertools . grouper ( num_rows , seq ) # result is now a list of columns... transpose it to return a list # of rows return zip ( * result )
Make a sequence into rows of num_columns columns.

	>>> tuple(make_rows(2, [1, 2, 3, 4, 5]))
	((1, 4), (2, 5), (3, None))
	>>> tuple(make_rows(3, [1, 2, 3, 4, 5]))
	((1, 3, 5), (2, 4, None))
Make a sequence into rows of num_columns columns .