Issue 17150: pprint could use line continuation for long string literals (original) (raw)
Created on 2013-02-07 12:51 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (8) |
|
|
msg181599 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2013-02-07 12:51 |
Currently: >>> pprint.pprint({"a": "xxx " * 50}) {'a': 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx '} It would be nicer if it produced something like: >>> pprint.pprint({"a": "xxx " * 50}) {'a': 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx ' 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx ' 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx ' 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx ' 'xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx '} (for the record, the real-world use case I encountered was when printing some pyudev data) |
|
|
msg181605 - (view) |
Author: Fred Drake (fdrake)  |
Date: 2013-02-07 13:25 |
I like this. It would be especially nice if it were smart enough to split the segments after sequences of line-ends (r'(\r?\n)+'). |
|
|
msg181643 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2013-02-07 19:49 |
I was thinking we could re-use textwrap, actually. |
|
|
msg184695 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2013-03-19 22:41 |
Here is a patch. |
|
|
msg184808 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2013-03-20 21:57 |
Here is a new patch with more tests and updated docs. |
|
|
msg185076 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-03-23 19:35 |
New changeset 5a2296093645 by Antoine Pitrou in branch 'default': Issue #17150: pprint now uses line continuations to wrap long string literals. http://hg.python.org/cpython/rev/5a2296093645 |
|
|
msg185077 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2013-03-23 19:37 |
Ok, I've committed the patch. |
|
|
msg185141 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2013-03-24 15:55 |
This is a nice addition. Thank you. |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:41 |
admin |
set |
github: 61352 |
2013-03-24 15:55:00 |
rhettinger |
set |
nosy: + rhettingermessages: + |
2013-03-23 19:37:04 |
pitrou |
set |
status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved |
2013-03-23 19:35:01 |
python-dev |
set |
nosy: + python-devmessages: + |
2013-03-20 21:57:41 |
pitrou |
set |
files: + str_pprint2.patchmessages: + |
2013-03-19 22:41:19 |
pitrou |
set |
files: + str_pprint.patchkeywords: + patchmessages: + stage: patch review |
2013-02-07 19:49:37 |
pitrou |
set |
messages: + |
2013-02-07 13:25:25 |
fdrake |
set |
messages: + |
2013-02-07 12:51:07 |
pitrou |
create |
|