Title: pprint with compact indent · Issue #112632 · python/cpython · GitHub
Open Graph Title: pprint with compact indent · Issue #112632 · python/cpython
X Title: pprint with compact indent · Issue #112632 · python/cpython
Description: Feature or enhancement Proposal: Add a new parameter to the pprint function that inserts a newline character (\n) after the opening parenthesis, and sets the indent to level * indent. With this parameter, pprint will format nested object...
Open Graph Description: Feature or enhancement Proposal: Add a new parameter to the pprint function that inserts a newline character (\n) after the opening parenthesis, and sets the indent to level * indent. With this par...
X Description: Feature or enhancement Proposal: Add a new parameter to the pprint function that inserts a newline character (\n) after the opening parenthesis, and sets the indent to level * indent. With this par...
Opengraph URL: https://github.com/python/cpython/issues/112632
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pprint with compact indent","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nAdd a new parameter to the pprint function that inserts a newline character (\\n) after the opening parenthesis, and sets the indent to level * indent. With this parameter, pprint will format nested objects in a manner similar to how formatters like Black or Ruff format them. \n\n```python\n\u003e\u003e\u003e t = {'a':2, 'b':{'x':3, 'y':{'t1': 4, 't2':5}}}\n\u003e\u003e\u003e pprint(t, indent=4, some_parameter=True)\n{\n \"a\": 2,\n \"b\": {\n \"x\": 3,\n \"y\": {\n \"t1\": 4,\n \"t2\": 5\n }\n }\n}\n```\nWith this change, pprint will print in a more width-compact manner, making it easier to read and copy-page pretty printed object to codebase wich follows similar formmating rule.\n\nThis feature was hevily inspired by this question on [Stackoverflow](https://stackoverflow.com/questions/3229419/how-to-pretty-print-nested-dictionaries)\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-129274\n* gh-136964\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/hyzyla","@type":"Person","name":"hyzyla"},"datePublished":"2023-12-02T23:10:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/112632/cpython/issues/112632"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dafd48d2-5ead-dfac-65c6-73e21eedf659 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B7FA:226804:ABFC0:E9EC1:6A52DCC8 |
| html-safe-nonce | 4fc51e7d52b3d1a61c028cf73cbadd7e7ccb489bdb66aec061181aa0041db6cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0ZBOjIyNjgwNDpBQkZDMDpFOUVDMTo2QTUyRENDOCIsInZpc2l0b3JfaWQiOiI0NjcyOTcyNDkzNDAwNzU5NDk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ceabc75e2d4e55a6995a7ecde6959c65e95556f2107e32345b37acd175b5eef3 |
| hovercard-subject-tag | issue:2022248611 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/112632/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8dbc61a9adc44f157ad1a2a4ee907bdcea478cf8fae0c675a91dd001a867d898/python/cpython/issues/112632 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8dbc61a9adc44f157ad1a2a4ee907bdcea478cf8fae0c675a91dd001a867d898/python/cpython/issues/112632 |
| og:image:alt | Feature or enhancement Proposal: Add a new parameter to the pprint function that inserts a newline character (\n) after the opening parenthesis, and sets the indent to level * indent. With this par... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hyzyla |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width