Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def columnize(items, width=80, cols=3):
- if not items:
- return False
- # Initialize a new table. No fancy border or headers, we just want a grid
- # of plain text (with any markup intact, of course).
- table = evtable.EvTable(border='none', width=width)
- # Break the flat list into sublists e.g. sublist([1,2,3,4,5], 2) ->
- # [[1,2], [3,4], [5]].
- out = sublist(items, cols)
- # Add each row.
- for x in out:
- table.add_row(*x)
- # Configure the columns to the desired width.
- #for x in range(len(out[0])):
- # table.reformat_column(x, width=width/cols)
- return str(table)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement