[Python-ideas] pprint in displayhook
Terry Reedy
tjreedy at udel.edu
Sat Sep 28 09:24:43 CEST 2013
On 9/27/2013 8:16 PM, Steven D'Aprano wrote:
> On Fri, Sep 27, 2013 at 01:07:18PM +0300, Serhiy Storchaka wrote:
>> What are you think about using pprint.pprint() to output the result of
>> evaluating an expression entered in an interactive Python session (and
>> in IDLE)?
>
> Well, let's try it and see...
>
>
> py> L = list(range(50))
> py> print(L)
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
> 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
> 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
> py> pprint.pprint(L)
> [0,
> 1,
> 2,
> 3,
> 4,
> 5,
> 6,
> 7,
> 8,
> 9,
> 10,
> 11,
> 12,
> 13,
> 14,
> 15,
> 16,
> 17,
> 18,
> 19,
> 20,
> 21,
> 22,
> 23,
> 24,
> 25,
> 26,
> 27,
> 28,
> 29,
> 30,
> 31,
> 32,
> 33,
> 34,
> 35,
> 36,
> 37,
> 38,
> 39,
> 40,
> 41,
> 42,
> 43,
> 44,
> 45,
> 46,
> 47,
> 48,
> 49]
>
>
> That would be an Absolutely Not.
This is why I suggested that I would consider making it available in
Idle on a per object basis, for things like this
>>> L = ['This is the first sentence.', 'This is the second, lets make
it onger', 'and this is the third, but do not stop yet']
>>> L
['This is the first sentence.', 'This is the second, lets make it
onger', 'and this is the third, but do not stop yet']
>>> import pprint
>>> pprint.pprint(L)
['This is the first sentence.',
'This is the second, lets make it onger',
'and this is the third, but do not stop yet']
But your example is more typical of my usage.
> However, if somebody wanted to give pprint some attention to make it
> actually pretty print, that would be very welcome.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list