New submission from Serhiy Storchaka <[email protected]>:
>>> from collections import OrderedDict
>>> od = OrderedDict([('a', 1), ('b', 2)])
>>> od.move_to_end('a')
>>> od
OrderedDict([('b', 2), ('a', 1)])
>>> dict(od)
{'a': 1, 'b': 2}
This affects also PEP 468.
>>> def f(**kwargs): return kwargs
...
>>> f(**od)
{'a': 1, 'b': 2}
And PEP 520.
>>> type('A', (), od).__dict__
mappingproxy({'a': 1, 'b': 2, '__module__': '__main__', '__dict__': <attribute
'__dict__' of 'A' objects>, '__weakref__': <attribute '__weakref__' of 'A'
objects>, '__doc__': None})
----------
components: Interpreter Core
messages: 322951
nosy: Rosuav, eric.snow, inada.naoki, rhettinger, serhiy.storchaka, steve.dower
priority: normal
severity: normal
status: open
title: Creating dict from OrderedDict doesn't preserve order
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34320>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com