[Python-ideas] should `dict` supply a default `__missing__` implementation?

Michael Selik michael.selik at gmail.com
Tue Jul 5 18:18:33 EDT 2016


On Tue, Jul 5, 2016 at 6:15 PM Neil Girdhar <mistersheik at gmail.com> wrote:

> Is it deprecated?
>
> I've seen this question a lot on stackoverflow:
> http://stackoverflow.com/questions/7148419/subclass-dict-userdict-dict-or-abc
>
> http://stackoverflow.com/questions/2390827/how-to-properly-subclass-dict-and-override-getitem-setitem
> http://stackoverflow.com/questions/10901048/i-want-to-subclass-dict-and-set-default-values
>
> I still have no idea what the right answer is.
>
> On Tue, Jul 5, 2016 at 6:11 PM Guido van Rossum <guido at python.org> wrote:
>
>> Because you shouldn't be using UserDict.
>>
>
Subclass dict when you only want to change exactly the methods you
override, and/or implement __missing__.

Subclass MutableMapping when you want to take advantage of the mixin
methods interacting with your implementations of the abstract methods.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160705/58f90808/attachment.html>


More information about the Python-ideas mailing list