[Python-Dev] Counter proposal: multidict (was: Proposal: defaultdict)

Guido van Rossum guido at python.org
Fri Feb 17 21:02:15 CET 2006

On 2/17/06, Ian Bicking <ianb at colorstudy.com> wrote:
> I really don't like that defaultdict (or a dict extension) means that
> x[not_found] will have noticeable side effects.  This all seems to be a
> roundabout way to address one important use case of a dictionary with
> multiple values for each key, and in the process breaking an important
> quality of good Python code, that attribute and getitem access not have
> noticeable side effects.
> So, here's a proposed interface for a new multidict object, borrowing
> some methods from Set but mostly from dict.  Some things that seemed
> particularly questionable to me are marked with ??.

Have you seen my revised proposal (which is indeed an addition to the
standard dict rather than a subclass)?

Your multidict addresses only one use case for the proposed behavior;
what's so special about dicts of lists that they should have special
support? What about dicts of dicts, dicts of sets, dicts of
user-defined objects?

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

More information about the Python-Dev mailing list