-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pprint could use line continuation for long string literals #61352
Comments
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) |
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)+'). |
I was thinking we could re-use textwrap, actually. |
Here is a patch. |
Here is a new patch with more tests and updated docs. |
New changeset 5a2296093645 by Antoine Pitrou in branch 'default': |
Ok, I've committed the patch. |
This is a nice addition. Thank you. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: