Skip to content

Instantly share code, notes, and snippets.

@stevekrenzel
Created July 17, 2011 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevekrenzel/1088119 to your computer and use it in GitHub Desktop.
Save stevekrenzel/1088119 to your computer and use it in GitHub Desktop.
Fancy Table (for Sab)
fancyTable = lambda table: '\n'.join("%%%ss " * min(map(len, table)) % tuple(max(map(len, x)) for x in zip(*table)) % tuple(x)[:min(map(len, table))] for x in table)
# You can try it by opening python and running:
# >>> fancyTable = lambda table: '\n'.join("%%%ss " * min(map(len, table)) % tuple(max(map(len, x)) for x in zip(*table)) % tuple(x)[:min(map(len, table))] for x in table)
# >>> print fancyTable([['Text', '1', 'a'], ['Longer Text', '123', 'abc'], ['Even longer text!', '123456789', 'abcdefghi']])
# Text 1 a
# Longer Text 123 abc
# Even longer text! 123456789 abcdefghi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment