3 ms·
You can also use defaultdict[0], or define the __missing__() method[1] yourself on a dictionary you receive from someone else's code. In either of these cases
by xiongchiamiov 16y ago
You can also use defaultdict[0], or define the __missing__() method[1] yourself on a dictionary you receive from someone else's code. In either of these cases the "not found" value will be whatever you decide it should be.
[0]: http://docs.python.org/library/collections.html#collections.defaultdict http://docs.python.org/library/collections.html#collections....
[1]: http://docs.python.org/library/stdtypes.html#dict http://docs.python.org/library/stdtypes.html#dict