I am quite new to Python and I am now struggling with formatting my data nicely for printed output.
I have one list that is used for two headings, and a matrix that
I think this is what you are looking for.
It's a simple module that just computes the maximum required width for the table entries and then just uses rjust and ljust to do a pretty print of the data.
If you want your left heading right aligned just change this call:
print >> out, row[0].ljust(col_paddings[0] + 1),
From line 53 with:
print >> out, row[0].rjust(col_paddings[0] + 1),