I just thought that using pprint.pprint was an elegant solution to the non-deterministic order of repr(dict) in doctest. See for instance http://bugs.python.org/issue3332 Contrary to sorted(foo().items()): - It provides a nice output that is exactly like a dict. - It supports any number of nested dicts. - It can be used in other cases as well to make doctests elegant.
I think suggesting pprint is a great idea. It also has another advantage in 3.4: in many cases it should produce output that is line wrapped such that NORMALIZE_WHITESPACE isn't needed. However, I'd make it as an *additional* suggestion. Pedagogically, sort makes it clear that you *must* resolve the problem of the ordering of dict items...then you can suggest pprint as something that also sorts, and has some additional nice properties as well.
That's a very good point. You'd think I'd have thought of it since I mentioned that it had changed in 3.4. And it will most likely change more in future versions.
History
Date
User
Action
Args
2022-04-11 14:57:57
admin
set
github: 64509
2014-01-21 06:23:30
r.david.murray
set
status: open -> closedresolution: rejectedmessages: + stage: resolved