[Python-ideas] Dict literal use for custom dict classes
Mike Miller
python-ideas at mgmiller.net
Wed Dec 16 13:47:22 EST 2015
On 2015-12-15 11:02, Paul Moore wrote:
> while it's a bit too special case on its own, one
> possibility would be to have
>
> callable{k1: v1, k2: v2, ...}
>
> be syntactic sugar for
>
> callable([(k1, k1), (k2, v2), ...])
Very interesting... I've faced the issue several times over the years when I've
wanted to unpack values into a function call in an ordered manner (but it hasn't
been available). Perhaps::
callable{**odict}
In fact with callables I'd even go so far as wish that ordered unpacking was the
default somehow, though I guess that probably isn't possible due to history.
So, would be happy to have a way to do it. The syntax looks slightly odd but I
could get used to it. I found this on the subject, don't know its status:
http://legacy.python.org/dev/peps/pep-0468/
--
-Mike
More information about the Python-ideas
mailing list