Issue19105
Created on 2013-09-27 13:50 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pprint_all_width.patch | serhiy.storchaka, 2013-10-02 16:47 | review | ||
| pprint_all_width_2.patch | serhiy.storchaka, 2014-11-28 19:38 | review | ||
| pprint_all_width_3.patch | serhiy.storchaka, 2014-12-20 19:48 | review | ||
| Messages (7) | |||
|---|---|---|---|
| msg198475 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2013-09-27 13:50 | |
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.
|
|||
| msg198851 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2013-10-02 16:47 | |
Here is a patch.
Without patch:
>>> pprint.pprint([[[[[[[[[[0, 0, 0]]*3]]]]]]]], width=21)
[[[[[[[[[[0,
0,
0],
[0,
0,
0],
[0,
0,
0]]]]]]]]]]
With patch:
>>> pprint.pprint([[[[[[[[[[0, 0, 0]]*3]]]]]]]], width=21)
[[[[[[[[[[0, 0, 0],
[0, 0, 0],
[0,
0,
0]]]]]]]]]]
|
|||
| msg231656 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2014-11-25 12:45 | |
Could anyone please make a review? |
|||
| msg231824 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2014-11-28 19:38 | |
Thank you Antoine for your review.
But first variant of the patch doesn't affect an example at the top of this issue, it doesn't change string formatting. The second variant makes string formatting use all free space at the right. With the patch:
>>> import pprint
>>> print('='*80) # a rule
================================================================================
>>> 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']]]]]]]]]]]]
Could you please make a review of new patch?
|
|||
| msg232982 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2014-12-20 19:48 | |
Resolved conflicts with issue19104. |
|||
| msg235954 - (view) | Author: Roundup Robot (python-dev) | Date: 2015-02-14 09:02 | |
New changeset 7a6671d491da by Serhiy Storchaka in branch 'default': Issue #19105: pprint now more efficiently uses free space at the right. https://hg.python.org/cpython/rev/7a6671d491da |
|||
| msg240104 - (view) | Author: Roundup Robot (python-dev) | Date: 2015-04-05 05:24 | |
New changeset 6d9520e2223f by Serhiy Storchaka in branch 'default': Updated pprint examples in according to issue #19105. https://hg.python.org/cpython/rev/6d9520e2223f |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:51 | admin | set | github: 63304 |
| 2015-04-05 05:24:43 | python-dev | set | messages: + msg240104 |
| 2015-02-14 14:09:23 | serhiy.storchaka | set | status: open -> closed assignee: serhiy.storchaka resolution: fixed stage: patch review -> resolved |
| 2015-02-14 09:02:38 | python-dev | set | nosy:
+ python-dev messages: + msg235954 |
| 2014-12-20 19:48:38 | serhiy.storchaka | set | files:
+ pprint_all_width_3.patch messages: + msg232982 |
| 2014-12-20 18:50:23 | serhiy.storchaka | link | issue17530 dependencies |
| 2014-11-28 19:38:51 | serhiy.storchaka | set | files:
+ pprint_all_width_2.patch messages: + msg231824 |
| 2014-11-25 12:45:53 | serhiy.storchaka | set | keywords:
+ needs review messages:
+ msg231656 |
| 2013-10-02 16:47:56 | serhiy.storchaka | set | files:
+ pprint_all_width.patch keywords: + patch messages: + msg198851 stage: needs patch -> patch review |
| 2013-09-27 13:50:34 | serhiy.storchaka | create | |