[Python-ideas] Columns for pprint.PrettyPrinter
John O'Connor
jxo6948 at rit.edu
Sat Aug 20 09:11:16 CEST 2011
This is slightly off topic but I recently came across a need to generate
some quick reports which had console based tabular output. I wondered if
there was a quick way to do table-like formatting with text. string.format()
is definitely
awesome but the sizing is fixed width. If you use a column delimiter, say
'|' for ex. you
have to put it in the format string. Automatically sizing table
columns based on the cell
value lengths would be helpful, and seems like an interesting idea but for
something other than pprint.
> or for something nested, which I'm less thrilled with, and haven't thought
> out how to implement unless you have a somewhat balanced structure, but for
> posterity:
>
> {"foo" :
> {"bar" : 1, {"hello" : 2, {"other" :
> 1,
> "baz" : 2, "world" : 1}, "thing" :
> 2,
> "foo" : 3},
> "here" : 3},
>
> ...
> }
>
That is not a valid python dict.
I think you may have been after something more like...
'foo': {
'bar': 1,
'baz': 2,
'biz': {
'x': 1,
'y': 2
}
}
which reflects the nesting and is suitable for the interpreter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110820/145ccbe7/attachment.html>
More information about the Python-ideas
mailing list