Calvin Spealman wrote: > [...] > ----------------------------------- > Creating dicts from dict subclasses > ----------------------------------- > > A common problem of subclassing built-in types (dict, in this case) arose trying > to move weakref.WeakValueDictionary to a subclass of dict, rather than UserDict. > > [NOTE: Could someone give a better description of this? I don't know enough of > the issue here to write any content full enough. Thanks.] The problem is that if you pass a mapping (i.e. something with a keys() method) to the dict constructor, it uses keys() and __getitem__() to make a copy. However if the argument is a subclass of dict, any overwritten keys() or __getitem__() methods are ignored. Servus, Walter
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4