Thursday, December 4, 2014

yade (yet another dict extension)

>>> from collections import defaultdict
>>> class TypeDict(dict):
...    def __missing__(self, key):
...       self[key] = defaultdict(key)
...       return self[key]
...
>>>
>>> td = TypeDict()
>>> td[float]['test']
0.0

1 comment:

  1. All of such improvement are before long be redeemable on the web - even those that state walk around like everything considered said. Expecting you have a Lakeland Discount Code from one of our sharp edge tastic.

    ReplyDelete