GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve documentation for `pprint` module · Issue #115986 · python/cpython

Improve documentation for pprint module #115986

New issue
Copy link
New issue
Copy link
Closed
Closed
Improve documentation for pprint module#115986
Copy link
Assignees
Privat33r-dev
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@AlexWaygood
AlexWaygood
opened on Feb 27, 2024
Issue body actions

Documentation

The documentation for the pprint module could be improved in many respects:

  • Most users will probably only ever need to use pprint.pp() or pprint.pprint(), but these are buried halfway down the module. It would be nice if these were the first things on the page.
  • All examples in the documentation use pprint.pprint(), which has some unexpected behaviour. For example, it sorts dictionaries by default, which is somewhat unintuitive now that dictionaries maintain insertion order. I suggest we change the examples to use pprint.pp() instead, which has the more intuitive default of sort_dicts=False.
  • Similarly, the docs for pprint.pprint() could explicitly call out that it has unintuitive defaults for things such as sort_dicts and link to pprint.pp()
  • Some links in the module's documentation incorrectly point to the module itself (pprint) instead of the function pprint.pprint().

These don't all necessarily need to be tackled in the same PR

Linked PRs

  • GH-115986 Fix pprint documentation #116019
  • [3.12] GH-115986 Reorder pprint docs and amend some references (GH-116019) #116061
  • [3.11] GH-115986 Reorder pprint docs and amend some references (#116019) #116064
  • gh-115986: Use param list to mark up pprint.PrettyPrinter constructor #116085
  • gh-115986: Fix inaccuracies in pprint docs #116104
  • [3.12] gh-115986: Fix inaccuracies in pprint docs (GH-116104) #116382
  • [3.11] gh-115986: Fix inaccuracies in pprint docs (GH-116104) #116383
  • GH-115986 Docs: promote pprint.pp usage as a default #116614
  • [3.12] GH-115986 Docs: promote pprint.pp usage as a default (GH-116614) #117196
  • [3.11] GH-115986 Docs: promote pprint.pp usage as a default (GH-116614) #117197
  • gh-115986 Improve pprint docs formatting #117401
  • gh-115986 Improve pprint documentation accuracy #117403
  • [3.12] gh-115986 Improve pprint documentation accuracy (GH-117403) #118146
  • [3.13] gh-115986 Improve pprint docs formatting (GH-117401) #121098
  • [3.12] gh-115986 Improve pprint docs formatting (GH-117401) #121099
Reacted by Hugo van Kemenade, Kerim Kabirov, Mattia, Erlend E. Aasland and Álvaro Mondéjar Rubio
Reacted by Beni Cherniavsky-Paskin

Activity

Next
  1. AlexWaygood
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Feb 27, 2024
  2. Privat33r-dev commented on Feb 27, 2024

    @Privat33r-dev
    Privat33r-dev
    on Feb 27, 2024
    Contributor
    More actions

    Can I be assigned? I can do most of it in a day or two.

  3. AlexWaygood
    assigned
    Privat33r-dev
    on Feb 27, 2024
  4. gaogaotiantian commented on Feb 27, 2024

    @gaogaotiantian
    gaogaotiantian
    on Feb 27, 2024
    Member
    More actions

    The fact pp is not an alias for pprint surprised me. Personally I'd prefer to use a function that better explains itself (pprint is easier to understand than pp), without knowing the difference between them. I have some doubts about using pp as the default in all the examples, but that's just my two cents.

  5. Privat33r-dev
    added a commit that references this issue on Feb 28, 2024

    pythonGH-115986 Doc: change 'pprint' module documentation's structure

    d2c3b7e
  6. Privat33r-dev commented on Feb 28, 2024

    @Privat33r-dev
    Privat33r-dev
    on Feb 28, 2024
    Contributor
    More actions

    Progress tracker

    • Most users will probably only ever need to use pprint.pp() or pprint.pprint(), but these are buried halfway down the module. It would be nice if these were the first things on the page.
    • All examples in the documentation use pprint.pprint(), which has some unexpected behaviour. For example, it sorts dictionaries by default, which is somewhat unintuitive now that dictionaries maintain insertion order. I suggest we change the examples to use pprint.pp() instead, which has the more intuitive default of sort_dicts=False.
    • Similarly, the docs for pprint.pprint() could explicitly call out that it has unintuitive defaults for things such as sort_dicts and link to pprint.pp()
    • Some links in the module's documentation incorrectly point to the module itself (pprint) instead of the function pprint.pprint().
  7. Privat33r-dev
    added 5 commits that reference this issue on Feb 28, 2024

    pythonGH-115986 Doc: change 'pprint' module documentation's structure

    72fefb5

    pythonGH-115986 Doc: change 'pprint' module documentation's structure

    2b27d73

    pythonGH-115986 Doc: change 'pprint' module documentation's structure

    67d090d

    pythonGH-115986 Doc: change 'pprint' module documentation's structure

    0170333

    pythonGH-115986 Doc: change 'pprint' module documentation's structure

    ff430ea
  8. Privat33r-dev commented on Feb 28, 2024

    @Privat33r-dev
    Privat33r-dev
    on Feb 28, 2024
    Contributor
    More actions

    Since pp as a default example might be considered controversial, I will put in the second PR. To avoid merging issues, I will push second PR after the first one is accepted.

  9. erlend-aasland commented on Feb 28, 2024

    @erlend-aasland
    erlend-aasland
    on Feb 28, 2024
    Contributor
    More actions

    The pprint docs could make good use of param list markup.

    UPDATE: PR => #116085

    Reacted by Alex Waygood and Kerim Kabirov
  10. erlend-aasland
    added a commit that references this issue on Feb 28, 2024

    GH-115986 Reorder pprint docs and amend some references (#116019)

    6c1c94d
  11. miss-islington
    added a commit that references this issue on Feb 28, 2024

    pythonGH-115986 Reorder pprint docs and amend some references (python…

    4bcf49a
  12. 28 remaining items

  13. miss-islington
    added a commit that references this issue on Apr 22, 2024

    pythongh-115986 Improve pprint documentation accuracy (pythonGH-117403)

    84a4186
  14. erlend-aasland
    added a commit that references this issue on Apr 22, 2024

    [3.12] gh-115986 Improve pprint documentation accuracy (GH-117403) (#…

    b1e5f27
  15. Privat33r-dev commented on Apr 26, 2024

    @Privat33r-dev
    Privat33r-dev
    on Apr 26, 2024
    Contributor
    More actions

    @erlend-aasland let's duplicate the params list in 1 function and in the class. DRY would be violated, but readability would be improved, which is more important than blindly following the principle.

  16. erlend-aasland commented on Apr 29, 2024

    @erlend-aasland
    erlend-aasland
    on Apr 29, 2024
    Contributor
    More actions

    @erlend-aasland let's duplicate the params list in 1 function and in the class. DRY would be violated, but readability would be improved, which is more important than blindly following the principle.

    Can you propose a PR?

    Reacted by Kerim Kabirov
  17. encukou
    added a commit that references this issue on Jun 27, 2024

    gh-115986 Improve pprint docs formatting (GH-117401)

    0890ad7
  18. Privat33r-dev commented on Jun 27, 2024

    @Privat33r-dev
    Privat33r-dev
    on Jun 27, 2024
    Contributor
    More actions

    I guess it's resolved? :)

  19. encukou commented on Jun 27, 2024

    @encukou
    encukou
    on Jun 27, 2024
    Member
    More actions

    let's duplicate the params list in 1 function and in the class. DRY would be violated, but readability would be improved, which is more important than blindly following the principle.

    Ah, I missed this comment before pointing it in the review, so, for posterity:

    IMO, including the full list only once, and linking to it from the other locations, is better -- especially with one function we prefer (pp), while others are backward-compatible defaults (pprint), and more special use (pformat & PrettyPrinter).
    Also, this way lends itself to listing the differences in argument order and defaults, which makes them much easier to spot.

    Thanks for implementing that! The PR was just merged.

    I guess it's resolved? :)

    I think so! @erlend-aasland, is there anything else you want to improve?

    Reacted by Kerim Kabirov and Erlend E. Aasland
  20. miss-islington
    added 2 commits that reference this issue on Jun 27, 2024

    pythongh-115986 Improve pprint docs formatting (pythonGH-117401)

    96807a1

    pythongh-115986 Improve pprint docs formatting (pythonGH-117401)

    c9b62d9
  21. erlend-aasland commented on Jun 27, 2024

    @erlend-aasland
    erlend-aasland
    on Jun 27, 2024
    Contributor
    More actions

    @erlend-aasland, is there anything else you want to improve?

    No, I think we're good for now :)

    Reacted by Petr Viktorin
    Reacted by Kerim Kabirov
  22. encukou
    added 2 commits that reference this issue on Jun 28, 2024

    [3.13] gh-115986 Improve pprint docs formatting (GH-117401) (GH-121098)

    394dc93

    [3.12] gh-115986 Improve pprint docs formatting (GH-117401) (GH-121099)

    3a420de
  23. encukou
    closed this as completedon Jun 28, 2024
  24. mrahtz
    added a commit that references this issue on Jun 30, 2024

    pythongh-115986 Improve pprint docs formatting (pythonGH-117401)

    ba4d054
  25. estyxx
    added a commit that references this issue on Jul 17, 2024

    pythongh-115986 Improve pprint docs formatting (pythonGH-117401)

    f298a44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Privat33r-dev
    Privat33r-dev

Labels

docsDocumentation in the Doc dirDocumentation in the Doc dir

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.