Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue17150

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:pprint could use line continuation for long string literals
Type:enhancementStage:resolved
Components:Library (Lib)Versions:Python 3.4
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: fdrake, pitrou, python-dev, rhettinger
Priority:normalKeywords:patch

Created on2013-02-07 12:51 bypitrou, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
str_pprint.patchpitrou,2013-03-19 22:41review
str_pprint2.patchpitrou,2013-03-20 21:57review
Messages (8)
msg181599 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)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)(Python committer)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)*(Python committer)Date: 2013-02-07 19:49
I was thinking we could re-use textwrap, actually.
msg184695 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2013-03-19 22:41
Here is a patch.
msg184808 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2013-03-20 21:57
Here is a new patch with more tests and updated docs.
msg185076 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2013-03-23 19:35
New changeset5a2296093645 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)*(Python committer)Date: 2013-03-23 19:37
Ok, I've committed the patch.
msg185141 -(view)Author: Raymond Hettinger (rhettinger)*(Python committer)Date: 2013-03-24 15:55
This is a nice addition.  Thank you.
History
DateUserActionArgs
2022-04-11 14:57:41adminsetgithub: 61352
2013-03-24 15:55:00rhettingersetnosy: +rhettinger
messages: +msg185141
2013-03-23 19:37:04pitrousetstatus: open -> closed
resolution: fixed
messages: +msg185077

stage: patch review -> resolved
2013-03-23 19:35:01python-devsetnosy: +python-dev
messages: +msg185076
2013-03-20 21:57:41pitrousetfiles: +str_pprint2.patch

messages: +msg184808
2013-03-19 22:41:19pitrousetfiles: +str_pprint.patch
keywords: +patch
messages: +msg184695

stage: patch review
2013-02-07 19:49:37pitrousetmessages: +msg181643
2013-02-07 13:25:25fdrakesetmessages: +msg181605
2013-02-07 12:51:07pitroucreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp