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

Serhiy Storchaka storchaka at gmail.com
Thu Aug 2 09:13:53 EDT 2018

27.07.18 16:29, Chris Angelico пише:
> Ah, fair point. Interestingly, the same problem hits repr(dict(od)),
> which I would have thought a reliable solution here. The simplest way
> that I've found is:
>>>> dict(od.items())
> {'b': 2, 'a': 1}
> That seems very odd. Iterating over the OD produces its keys in the
> correct order (b, a), but constructing a dict from it ignores
> iteration order and just goes "oh hey, this is a dict, we can snag
> that". Is that correct?

This looks like a bug to me. Opened https://bugs.python.org/issue34320 .

More information about the Python-ideas mailing list