On Dec 19, 2017, at 20:32, Nathaniel Smith <n...@pobox.com> wrote:

> I guess the underlying issue here is partly the question of what the
> pprint module is for. In my understanding, it's primarily a tool for
> debugging/introspecting Python programs, and the reason it talks about
> "valid input to the interpreter" isn't because we want anyone to
> actually feed the data back into the interpreter, but to emphasize
> that it provides an accurate what-you-see-is-what's-really-there view
> into how the interpreter understands a given object. It also
> emphasizes that this is not intended for display to end users; making
> the output format be "Python code" suggests that the main intended
> audience is people who know how to read, well, Python code, and
> therefore can be expected to care about Python's semantics.

pprint.pprint() is indeed mostly for debugging, but not always.  As an example 
of what will break if you change the sorting guarantee: in Mailman 3 the REST 
etag is calculated from the pprint.pformat() of the result dictionary before 
it’s JSON-ified.  If the order is changed, then it’s possible a client will 
have an incorrect etag for a structure that is effectively the same.

-Barry

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to