Skip to content

Improve documentation for pprint module #115986

Closed
@AlexWaygood

Description

@AlexWaygood

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

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions