OrderedDict with kwds

Albert-Jan Roskam sjeik_appie at hotmail.com
Sat Apr 22 04:18:20 EDT 2017

From: eryk sun <eryksun at gmail.com>
Sent: Saturday, April 22, 2017 7:59 AM
To: Python Main
Cc: Albert-Jan Roskam
Subject: Re: OrderedDict with kwds
On Fri, Apr 21, 2017 at 6:08 PM, Albert-Jan Roskam
<sjeik_appie at hotmail.com> wrote:
> Would the insertion order be preserved if the last line were to be
> replaced with:
> if kwds:
>     for k, v in kwds.items():
>         self[k] = v
> if args:
>     self.__update(*args)  # no **kwds!

The basic problem is that kwds is a regular, unordered dict:

    def f(**kwds):

    >>> f()
    <class 'dict'>

----> Hi Eryk,

Yes, I realized this later that evening (probably thanks to can of cold beer :-)). But there is hope: https://www.python.org/dev/peps/pep-0468/ . Do you know if there is/will be a "from __future__" to backport that behavior? We're using Python 3.5 now.

Thank you!


More information about the Python-list mailing list