kw to be ordered dict

I have a piece of code that essentially reimplements OrderedDict. I have been wondering why the key ordered is not preserved correctly (tests fail). c = Container(a=1,b=2,c=3,d=4) self.assertEqual(c.keys(), ["a","b","c","d"]) self.assertEqual(c.values(), [1,2,3,4]) self.assertEqual(c.items(), [("a",1),("b",2),("c",3),("d",4)]) Then I looked at collections.OrderedDict ctor docstring and it says "Initialize an ordered dictionary. The signature is the same as regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary." I expected the **kw to reproduce the same order as actual keyword arguments. The only right way to solve it, as it seems to me, would be to make **kw an OrderedDict. Arkadiusz Bulski

This has been discussed before. See for example https://mail.python.or g/pipermail/python-ideas/2010-October/008445.html There's even PEP about this: https://www.python.org/dev/peps/pep-0468

And there is a patch already. http://bugs.python.org/issue27350 On Mon, Sep 5, 2016 at 5:32 AM, Riley Banks <waultah@gmail.com> wrote:
-- INADA Naoki <songofacandy@gmail.com>

Arek Bulski <arek.bulski@gmail.com> wrote:
FYI: A change that keeps the order of **kw was just committed, so 3.6 will have that behavior: https://mail.python.org/pipermail/python-dev/2016-September/146327.html Sebastian

This has been discussed before. See for example https://mail.python.or g/pipermail/python-ideas/2010-October/008445.html There's even PEP about this: https://www.python.org/dev/peps/pep-0468

And there is a patch already. http://bugs.python.org/issue27350 On Mon, Sep 5, 2016 at 5:32 AM, Riley Banks <waultah@gmail.com> wrote:
-- INADA Naoki <songofacandy@gmail.com>

Arek Bulski <arek.bulski@gmail.com> wrote:
FYI: A change that keeps the order of **kw was just committed, so 3.6 will have that behavior: https://mail.python.org/pipermail/python-dev/2016-September/146327.html Sebastian
participants (4)
-
Arek Bulski
-
INADA Naoki
-
Riley Banks
-
Sebastian Krause