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
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com