Dictionary inheritance

Talin talin at acm.org
Fri Aug 12 15:44:11 EDT 2005


I want to make a dictionary that acts like a class, in other words, 
supports inheritance: If you attempt to find a key that isn't present, 
it searches a "base" dictionary, which in turn searches its base, and so on.

Now, I realize its fairly trivial to code something like this using 
UserDict, but given that classes and modules already have this behavior, 
is there some built-in type that already does this?

(This is for doing nested symbol tables and such.)

---

Also, on a completely different subject: Has there been much discussion 
about extending the use of the 'is' keyword to do type comparisons a la 
C# (e.g. "if x is list:") ?

-- Talin




More information about the Python-list mailing list