New submission from Serhiy Storchaka:

pprint not only adds indentation, but also increases right margin for nested 
items.

>>> pprint.pprint([' '.join(str(i) for i in range(30))]*2)
['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',
 '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']
>>> pprint.pprint([[[[[[[[[[[[' '.join(str(i) for i in range(30))]]]]]]]]]]]]*2)
[[[[[[[[[[[['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']]]]]]]]]]],
 [[[[[[[[[[['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']]]]]]]]]]]]

As you can see in second example there is a place for at least '21 22 23 ' at 
the right. In case of multiline representation of nested items pprint can 
reserve space only at the end of last line and continue inner lines to full 
width.

----------
components: Library (Lib)
messages: 198475
nosy: fdrake, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: pprint doesn't use all width
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19105>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to