[Python-Dev] Re: A small proposed change to dictionaries' "get" method
Guido van Rossum
guido@beopen.com
Mon, 07 Aug 2000 07:38:11 -0500
> > dict.default('hello', []).append('hello')
>
> Is this new method going to apply to dictionaries only,
> or is it to be considered part of the standard mapping
> interface?
>
> If the latter, I wonder whether it would be better to
> provide a builtin function instead. The more methods
> are added to the mapping interface, the more complicated
> it becomes to implement an object which fully complies
> with the mapping interface. Operations which can be
> carried out through the basic interface are perhaps
> best kept "outside" the object, in a function or
> wrapper object.
The "mapping interface" has no firm definition. You're free to
implement something without a default() method and call it a mapping.
In Python 3000, where classes and built-in types will be unified, of
course this will be fixed: there will be a "mapping" base class that
implements get() and default() in terms of other, more primitive
operations.
--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)