Created
July 17, 2011 21:51
-
-
Save stevekrenzel/1088119 to your computer and use it in GitHub Desktop.
Fancy Table (for Sab)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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