Comment 1 for bug 1035478

Revision history for this message
Vish Ishaya (vishvananda) wrote :

Three options for fixing. I'm using set_default in the examples, but it applies to set_override as well.

1) make set_default('foo', None) override the default with the value None and provide a clear_default('foo') method to remove it. Internally we store the NoneValue with a special class.

2) provide a NoneValue class that can be used to override the default value with a None, set_default('foo', NoneValue()) will override the internal value. set_default('foo', None) will clear the default as it does today.

3) allow set_default to take a method. When the value is retrieved, the method is lazily evaluated. You could do something like set_default('foo', lambda: None) to override a value with None. set_default('foo', None) will clear the default as it does today. This definitely is interesting but it seems a little complex and Non-obvious

Option 1 changes the existing api very slightly, but it seems more correct. In order to keep compatibility and keep things simple I've implemented 2). Open to suggestions on the review