[Python-ideas] pprint in displayhook

Steven D'Aprano steve at pearwood.info
Wed Oct 2 02:56:45 CEST 2013


On Sun, Sep 29, 2013 at 11:38:30PM +0300, Serhiy Storchaka wrote:
> 28.09.13 07:17, Raymond Hettinger написав(ла):
> >This might be a reasonable idea if pprint were in better shape.
> >I think substantial work needs to be done on it, before it would
> >be worthy of becoming the default method of display.
> 
> What should be changed in pprint?

I would like to see pprint be smarter about printing lists and dicts. At 
the moment, a long list is either printed all on one line, like the 
default display, or one item per line. This can end up as one long, 
narrow column, which is worse than the default. I'd like to see it be 
smarter about using multiple columns.

E.g. pprint([1, 2, 3, ... 1000])

rather than this:

[1, 
 2, 
 3, 
 ...
 998,
 999,
 1000]

something like this:

[1,    2,    3,    4,    5,    6,    7,    8,    9,   10,
 ...  
 991,  992,  993,  994,  995,  996,  997,  998,  999, 1000]





-- 
Steven


More information about the Python-ideas mailing list