Dictionary inheritance

Raymond Hettinger python at rcn.com
Sat Aug 13 01:17:22 EDT 2005


[Talin]
> 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.

Perhaps the chainmap() recipe will meet your needs:

   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305268


Raymond




More information about the Python-list mailing list