I need to define some key-value parameters to configure the behaviour of a class. My requirements are two:
- To be able to process them programatically
- To be able to make more specific configurations that overwrite some of the values.
The natural approach for the first requirement is to use a dict
(so I can loop over keys, values or items with a for
loop), but for the second requirement it seems more appropriate to use a class hierarchy and let the attribute lookup mechanism to do the work (plus I get other goodies like being able to use properties for some values).
Is there a way to get best of both worlds?
After reading the comments, It does not need to be mutable (I won't be changing the values of an already created instance), it's just for static configuration. But I might need to add new values in a more specific instance.
I think in the end I could just use a dict.copy
+ dict.update
for the specific instances (I can live without the properties).