Mike Rovner <[EMAIL PROTECTED]> writes:
> It can be tipped like that:
> 
> di = dict(int)
> di.setdefault(0)
> di[key] += 1
...
> But the point is that if method not found in dict it delegated to
> container type specified in constructor.
> 
> It solves dict specialization without bloating dict class and is generic.

Hey, I like that.  I'd let the default be an optional extra arg to the
constructor:

   di = dict(int, default=0)
   di[key] += 1

without the setdefault.  I might even add optional type checking:

  di = dict(int, default=0, typecheck=True)
  di[key] = 'foo'    # raises TypeError
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to