a dictionary from a list

Jp Calderone exarkun at divmod.com
Sat Jun 25 09:56:51 EDT 2005


On Sat, 25 Jun 2005 09:10:33 -0400, Roy Smith <roy at panix.com> wrote:
>Terry Hancock <hancock at anansispaceworks.com> wrote:
>> Before the dict constructor, you needed to do this:
>>
>> d={}
>> for key in alist:
>>     d[key]=None
>
>I just re-read the documentation on the dict() constructor.  Why does it
>support keyword arguments?
>
>   dict(foo="bar", baz="blah") ==> {"foo":"bar", "baz"="blah"}
>
>This smacks of creeping featurism.  Is this actually useful in real code?

Constantly.

Jp



More information about the Python-list mailing list