[Python-Dev] dict() enhancement idea?

Brett Cannon bac@OCF.Berkeley.EDU
Thu, 21 Nov 2002 18:00:51 -0800 (PST)


[Just van Rossum]

> I sometimes use an idiom like
>
>   def dictfromkeywords(**kwargs):
>       return kwargs
>
>   d = dictfromkeywords(
>           akey = 12,
>           anotherkey = "foo",
>           ...etc.
>   )
>

+1

So far everyone who has responded to this idea has admitted they have code
somewhere the operates like this.

> to conveniently build dicts with literal keys. I think I've seen Alex Martelli
> advertise it, too. Don't know how well known it is otherwise, but it is extremly
> handy.
>

I think Alex has it in the Cookbook.

-Brett