[Python-Dev] Proposal: defaultdict

Guido van Rossum guido at python.org
Mon Feb 20 21:54:42 CET 2006

On 2/20/06, Josiah Carlson <jcarlson at uci.edu> wrote:
> "Adam Olsen" <rhamph at gmail.com> wrote:
> > Can you say, for the record (since nobody else seems to care), if
> > d.getorset(key, func) would work in your use cases?
> It doesn't work for the multiset/accumulation case:
>     dd[key] += 1

This is actually a fairly powerful argument for a subclass that
redefines __getitem__ in favor of a new dict method. (Not to mention
that it's much easier to pick a name for the subclass than for the
method. :-) See the new thread I started.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list