I was looking for a solution with unknown columns width to print a database table. So here it is:
def printTable[myDict, colList=None]:
""" Pretty print a list of dictionaries [myDict] as a dynamically sized table.
If column names [colList] aren't specified, they will show in random order.
Author: Thierry Husson - Use it as you want but don't blame me.
"""
if not colList: colList = list[myDict[0].keys[] if myDict else []]
myList = [colList] # 1st row = header
for item in myDict: myList.append[[str[item[col] if item[col] is not None else ''] for col in colList]]
colSize = [max[map[len,col]] for col in zip[*myList]]
formatStr = ' | '.join[["{{: