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
should be:

def get(self, key, default = None):
  try:
    return self[key]
  except KeyError:
    return default
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to