[Python-ideas] Change repr of collections.OrderedDict to be more dict-like

Grégory Lielens gregory.lielens at gmail.com
Thu Jul 26 04:24:04 EDT 2018


I would wait a little bit. OrderedDict will probable become a pure synonym 
for dict,
in a few releases, and the repr issue will solve itself, both giving the 
even simpler/nicer {'a': '1', 'b': '2'}

Your proposal expose that dicts are ordered (which they are, but it's 
hidden). Once exposed, OrderedDict are obsolete and should be in the 
namespace only for backward compatibitlity.

On Thursday, July 26, 2018 at 10:13:12 AM UTC+2, Miro Hrončok wrote:
>
> Hi,
>
> now when dicts are sorted, can we change the repr of 
> collections.OrderedDict to look like dict?
>
> I mean from:
>
>      OrderedDict([('a', '1'), ('b', '2')])
>
> To:
>
>      OrderedDict({'a': '1', 'b': '2'})
>
> I assume the current list-of-tuples repr is there so copy pasting the 
> repr to the interpreter results in the same OrderedDict. When dicts 
> preserve insertion order, this now works with dict.
>
> I consider the dict-based repr much easier to read.
>
> Thoughts?
> -- 
> Miro Hrončok
> --
> Phone: +420777974800
> IRC: mhroncok
> _______________________________________________
> Python-ideas mailing list
> Python... at python.org <javascript:>
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180726/721419a9/attachment.html>


More information about the Python-ideas mailing list