[Python-ideas] Columns for pprint.PrettyPrinter

Fred Drake fdrake at acm.org
Sun Sep 11 20:52:23 CEST 2011


On Fri, Aug 19, 2011 at 7:23 PM, Julian Berman <julian at grayvines.com> wrote:
> it could be coerced into something like
>
>    >>> pprint.pprint(range(30), columns=5)
>    [0, 1, 2, 3, 4
>     3, 4, 5, 6, 7, ... ]

I'd love to see something like this added.  Another possibility would be
something that figures out how many columns would be appropriate based on
the available (remaining) width.

> 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},
>
>      ...
>      }

This is just a little frightening.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at acm.org>
"A person who won't read has no advantage over one who can't read."
   --Samuel Langhorne Clemens



More information about the Python-ideas mailing list