Re: [Python-Dev] Possible wrong behavior of the dict?

2015年3月17日 13:16:22 -0700

* Zaur Shibzukhov <[email protected]> [2015年03月17日 22:29:07 +0300]:
> Yes... But I expected that dict constructor will use `__getitem__` or
> `items` method of MyDict instance in order to retrieve items of the MyDict
> instance during construction of the dict instance... Instead it interpreted
> MyDict instance as the dict instance during construction of new dict.This
> exactly caused my confusion.
Subclassing builtins is always a recipe for trouble, because the C
implementation doesn't necessarily call your Python methods.
You should probably use collections.UserDict or
collections.abc.(Mutable)Mapping instead:
https://docs.python.org/3/library/collections.html#collections.UserDict
https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping
Florian
-- 
http://www.the-compiler.org | [email protected] (Mail/XMPP)
 GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
 I love long mails! | http://email.is-not-s.ms/

Attachment: pgp57NLMvC4Lp.pgp
Description: PGP signature

_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to