OrderedDict with kwds

eryk sun eryksun at gmail.com
Sat Apr 22 03:59:45 EDT 2017


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):
        print(type(kwds))

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



More information about the Python-list mailing list