defaultdict's bug or feature?
redforks at gmail.com
Thu May 21 14:07:50 CEST 2009
from collections import defaultdict
d = defaultdict(set)
assert isinstance(d['a'], set)
assert isinstance(d.get('b'), set)
d['a'] is ok, and a new set object is insert to d, but d.get('b') won't.
It's a bug, or just a feature?
I think dict.get() method is just a *safe* version of dict[key], maybe it
def get(self, key, default = None):
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list