3 ms·
I’m not 100% sure (and on my phone) but I think the idiomatic way would be to subclass https://docs.python.org/3/library/collections.abc.html#collections.abc.Mu
by hynek 5y ago
I’m not 100% sure (and on my phone) but I think the idiomatic way would be to subclass https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping https://docs.python.org/3/library/collections.abc.html#colle...
- hprotagonist 5y agoand even then, it's a faff and a half: https://treyhunner.com/2019/04/why-you-shouldnt-inherit-from-list-and-dict-in-python/ https://treyhunner.com/2019/04/why-you-shouldnt-inherit-from...
- neoncontrails 5y ago> The UserDict class initializer makes a dictionary which it stores in self.data. All of the methods on this dictionary-like UserDict class wrap around this self.data dictionary. Incredible. This appears to be exactly the solution to my problem. Thanks! (And, if thunner happens to come across this: thanks, from a former TA of yours!)