[IPython-dev] display of dicts?

Steve Holden steve at holdenweb.com
Tue Dec 19 12:50:28 EST 2017


On Tue, Dec 19, 2017 at 5:37 PM, Thomas Kluyver <takowl at gmail.com> wrote:

> On 19 December 2017 at 17:24, Chris Barker <chris.barker at noaa.gov> wrote:
>
>> Granted, string keys where alphabetization makes sense are pretty darn
>> common, but still a "special case"
>>
>
> I'd argue that they're common enough to be the typical case, though
> perhaps my definition of 'makes sense' is a bit broader than yours. And
> sorting can also make sense for numeric keys.
>
>
>> In fact, I discovered this with this example, which I used in my intro to
>> Python class to demonstrate dict's arbitrary order
>>
>
> I think this is exactly the tension we're facing. People teaching intro to
> Python courses want to show what a dictionary *is*, and you don't want
> IPython's features to obscure that. But other than learning about
> dictionaries, I suspect that sorted order is useful more often than
> insertion order.
>
> I'm leaning slightly towards making insertion order the default in Python
> 3.7 - it will be meaningful some of the time, and it is now part of what a
> dict is - but I think we should ensure the same release adds an easy way to
> switch back to displaying sorted dicts.
>

​What about adding a "sorted" method to dicts that produces a dict with the
same keys but the keys inserted ​in sorted order?

regards
 Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20171219/c3a3cad0/attachment.html>


More information about the IPython-dev mailing list