# About \`defaultdict.\_\_missing\_\_\`

**URL:** <https://discuss.python.org/t/about-defaultdict-missing/106922>\
**Category:** Core Development\
**Created:** [April 10, 2026, 9:58am UTC](https://discuss.python.org/t/about-defaultdict-missing/106922 "2026-04-10T09:58:56Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![JamesParrott](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamesparrott/32/10534_2.png) [@JamesParrott](https://discuss.python.org/u/JamesParrott)\
**Post date:** [April 11, 2026, 1:05pm UTC](https://discuss.python.org/t/about-defaultdict-missing/106922/11 "2026-04-11T13:05:44Z")

</div>

My 2p personally - if a user wants to call setdefault, they should do so explicitly. And if they do that, then beyond nicer syntax and ergonomics, they don’t really need a defaultdict at all.

> Does anyone have any actual use that is broken by this change?

I have actually tried to write code overriding `defaultdict. __missing__ `, and calling the original with super. I had to switch out `.default_factory` for my purpose (selecting a particular factory depending on the key) and rapidly gave up. Simply overriding ` __getitem__ ` on a regular dict instead was an order of magnitude less hassle.

That does probably mean very few people have ever done it. But I would say it also means the code written by those who have done it, is highly likely to be easily broken.

```py
class MultiFactoryDefaultDict(defaultdict):
        factories = {'a': list
                    ,'b': int
                    }
        

        def __missing__ (self, key):
            tmp = self.default_factory
            self.default_factory = self.factories.get(key, tmp)
            retval = super(). __missing__ (key)
            self.default_factory = tmp
            return retval

```

---

_[View the full topic](https://discuss.python.org/t/about-defaultdict-missing/106922)._
