[Python-ideas] OrderedDict literals

Eric Snow ericsnowcurrently at gmail.com
Wed Mar 19 22:24:16 CET 2014


On Wed, Mar 19, 2014 at 2:00 AM, David Mertz <mertz at gnosis.cx> wrote:
> It doesn't feel to me like the existing (non-literal) spelling is
> particularly bad:
>
>>>> o1 = OrderedDict(foo=1, bar=2, baz=3)
>>>> o2 = OrderedDict([('foo',1), ('bar',2), ('baz',3)])
>>>> o1
> OrderedDict([('bar', 2), ('foo', 1), ('baz', 3)])
>>>> o2
> OrderedDict([('foo', 1), ('bar', 2), ('baz', 3)])
>
> So sure, you can't use the kw=val style of initialization,

FYI I'm working on a proposal to support preserving the call order of
**kwargs.  This would allow initializing an OrderedDict correctly
using keyword args.  I may have something to show for it by the end of
the PyCon sprints.

-eric


More information about the Python-ideas mailing list