I need a dict that inherits its mappings
samwyse at gmail.com
Thu Jun 25 08:31:04 EDT 2009
I need a dict-like object that, if it doesn't contain a key, will
return the value from a "parent" object. Is there an easy way to do
this so I don't have to define __getitem__ and __contains__ and others
that I haven't even thought of yet? Here's a use case, if you're
en_GB['bonnet']='part of your car'
print en_US['bonnet'] # prints 'part of your car'
en_US['bonnet']='a type of hat'
print en_US['bonnet'] # prints 'a type of hat'
print en_GB['bonnet'] # prints 'part of your car'
More information about the Python-list