Using Python 2.4, how do I print a list in a nice tabular format?
My list is in the below format.
mylist=[(('VAL1', 'VAL2', 'VAL3', 'VAL4', 'VAL5', 'VAL6'), AGGREGATE_VALUE)]
I have tried pprint, but it does not print the result in a tabular format.
EDIT : I would like to see the output in the below format:
VAL1 VAL2 VAL3 VAL4 VAL5 VAL6 AGGREGATE_VALUE
This table, should account for variable item lengths and still print with proper indentation.
result
Don’t know if this fills your need
EDIT 1
Using string formatting with modulo operator (%) to print in a constant length, ‘%6s’ right-justifies in a constant length of 6, and ‘%-6s’ left-justifies in a constant length of 6.
You’ll find precisions here
But there is no sense to specify a constant length to print something at the end of a string, because it’s somewhat naturally-left-justified in this case.
Then :
EDIT 2
EDIT 3
result
Note that this kind of formatting would be much easier with the string’s method format() introduced in Python 2.6