def cols(lst, ncols):
 nrows = int(math.ceil(((1.0 * len(lst)) / ncols)))
 lst = (lst + [None for i in range(len(lst), (nrows * ncols))])
 cols = [lst[i:(i + nrows)] for i in range(0, (nrows * ncols), nrows)]
 rows = zip(*cols)
 rows = [filter((lambda x: (x is not None)), r) for r in rows]
 return rows

def cols ( lst , ncols ) : nrows = int ( math . ceil ( ( ( 1.0 * len ( lst ) ) / ncols ) ) ) lst = ( lst + [ None for i in range ( len ( lst ) , ( nrows * ncols ) ) ] ) cols = [ lst [ i : ( i + nrows ) ] for i in range ( 0 , ( nrows * ncols ) , nrows ) ] rows = zip ( * cols ) rows = [ filter ( ( lambda x : ( x is not None ) ) , r ) for r in rows ] return rows
divides a list into columns .