Insert missing keys using defaultdict

Gnarlodious gnarlodious at gmail.com
Thu Mar 11 17:27:24 CET 2010


On Mar 11, 9:20 am, George Sakkis wrote:

> > How do create a dict assigning every missing key with a default
> > string?
>
> "<a class='%(Style)s' href='%(Ref)s' title='%(Tip)s'>%(Text)s</a>" %
> defaultdict(lambda:'_MISSING_', plistDict)

Brilliant, I love Python.

-- Gnarlie




More information about the Python-list mailing list