[IPython-dev] Incompatible change discussion: Pretty printing of ordered dict.

Wes Turner wes.turner at gmail.com
Fri Aug 4 10:36:12 EDT 2017


```python
repr(dict)

import pprint
pprint.pprint(dict)
print(pprint.pformat(dict)
```

On Friday, August 4, 2017, MinRK <benjaminrk at gmail.com> wrote:

> I'm pretty strongly in favor of keeping the sorting in our default
> pretty-printing. It's extremely valuable for interacting with dictionaries
> to have consistent, predictable display. There are plenty of ways to
> illustrate dict ordering, such as by iterating through the dict , e.g.
> `list(dict)`.
>
> -Min
>
> On Thu, Aug 3, 2017 at 6:38 PM, Carl Smith <carl.input at gmail.com
> <javascript:_e(%7B%7D,'cvml','carl.input at gmail.com');>> wrote:
>
>> I'm with Thomas.
>>
>> On Wed, 2 Aug 2017 22:30 Wes Turner, <wes.turner at gmail.com
>> <javascript:_e(%7B%7D,'cvml','wes.turner at gmail.com');>> wrote:
>>
>>> Maybe a SORT_DICT_KEYS bool configuration setting? Really practically
>>> only in order to teach:
>>>
>>> - dict
>>>   - https://docs.python.org/3/tutorial/datastructures.html#dictionaries
>>> - PYTHONHASHSEED / -R
>>>   - https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHASHSEED
>>>   - https://docs.python.org/3/using/cmdline.html#cmdoption-R
>>> - collections.OrderedDict (is backwards compatible)
>>>   - https://docs.python.org/3/library/collections.html#ordered
>>> dict-objects
>>>
>>>
>>>
>>> On Wednesday, August 2, 2017, Matthias Bussonnier <
>>> bussonniermatthias at gmail.com
>>> <javascript:_e(%7B%7D,'cvml','bussonniermatthias at gmail.com');>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> As you may or may not be aware, with Python 3.6 the dictionary are
>>>> ordered by default. It is technically an implementation detail, though
>>>> some people would love for it not to.
>>>>
>>>> Regardless, IPython has for a long time pretty-printed the dictionary
>>>> with _sorted_ keys, this thus prevent to teach python and show that
>>>> dictionaries maintain order. Thus there is the question of wether we
>>>> should disable sorting keys while pretty-printing.
>>>>
>>>> https://github.com/ipython/ipython/issues/10110
>>>>
>>>> This seem like a minor change, but I'd like to know if some of you are
>>>> _relying_ on the ordering of dict when they are printed, or have
>>>> compelling arguments against (or for) removing sorting of the keys
>>>> before pretty_printing.
>>>>
>>>> If you care about the above subject, please have your voice heard in
>>>> above issue.
>>>>
>>>> Thanks,
>>>> --
>>>> Matthias
>>>> _______________________________________________
>>>> IPython-dev mailing list
>>>> IPython-dev at python.org
>>>> https://mail.python.org/mailman/listinfo/ipython-dev
>>>>
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at python.org
>>> <javascript:_e(%7B%7D,'cvml','IPython-dev at python.org');>
>>> https://mail.python.org/mailman/listinfo/ipython-dev
>>>
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at python.org
>> <javascript:_e(%7B%7D,'cvml','IPython-dev at python.org');>
>> https://mail.python.org/mailman/listinfo/ipython-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20170804/55e72e63/attachment-0001.html>


More information about the IPython-dev mailing list