Table¶
cli2 also offers a simple table rendering data that will do it’s best to word wrap cell data so that it fits in the terminal.
This Table module behaves like a list, and is pretty simple. Its purpose is to tabulate data and it’s going to brute force output sizes until it finds a match.
As such, it’s not a good module to display really a lot of data because it sacrifies performance for human readability.
cli2.Table.factory(['foo', 'bar'], ['much longer', 'test']).print()
foo bar
much longer test
Note
This would look better with color
cli2.Table.factory(dict(foo=1, bar=2), dict(foo=3, bar=4)).print()
Renders:
foo bar
=== ===
1 2
3 4