I have always been confused and falling over the minute details while inheriting the builtin types in Python e.g. list and dict.
Can you please point to the tutorials and docs which give a comprehensive details about the internals and the syntax involved.
Python Language Reference, §3.4.6, "Emulating container types"
Take a look at the custom trackingdict
class in my answer to a different Stack Overflow question titled Recursive diff of two python dictionaries (keys and values) which shows it actually being done. It overrides all the methods which can mutate a dictionary object.
this is for Dict:
http://docs.python.org/library/userdict.html
Edit
update userdict docs link:
https://docs.python.org/2/library/userdict.html
精彩评论