a dictionary from a list
Michael Hoffman
cam.ac.uk at mh391.invalid
Sat Jun 25 10:26:41 EDT 2005
Roy Smith wrote:
> 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?
Personally, I use it all the time. It's a much more convenient literal
for a dictionary. And before it was introduced I used this utility function:
def mkdict(**kwargs):
return kwargs
--
Michael Hoffman
More information about the Python-list
mailing list