On Tue, Dec 19, 2017 at 8:14 AM, Barry Warsaw <ba...@python.org> wrote:
> On Dec 18, 2017, at 22:37, Nathaniel Smith <n...@pobox.com> wrote: > > > Wait, what? Why would changing pprint (so that it accurately reflects > > dict's new underlying semantics!) be a breaking change? Are you > > suggesting it shouldn't be changed in 3.7? > > As others have pointed out, exactly because the current behavior is > documented. And we all know that if it’s documented (and often even if > it’s not, but that’s besides the point here) it will be relied upon. > Nathaniel Smith has pointed out that eval(pprint(a_dict)) is supposed to return the same dict -- so documented behavior may already be broken. (though I assume order is still ignored when comparing dicts, so: eval(pprint(a_dict)) == a_dict will still hold. But practicality beats purity, and a number of folks have already posted use-cases where they rely on sorted order, so there you go. > So we can’t change the default behavior. But I have no problems > conceptually with giving users options. The devil is in the details > though, e.g. should we special case dictionary sorting only? > Should we use a sort `key` to mirror sorted() and list.sort()? > That would be a nice feature! If anything is done, I think we should allow a key function. and maybe have key=None as "unsorted" -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ 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