Optional parameters
Providing a value to the default
keyword upon parameter instantiation will make that parameter optional in a sense that it can be omitted in the configuration source. In that case the default value will be chosen instead.
Sometimes, however, it might be useful to know whether a parameter's value was loaded from the configuration source or if it used the default. Suppose you have an Integer representing the seed for RNG and in case the user doesn't specify a RNS seed you'd like to use the current sytem time. Setting Integer(default=None)
doesn't help because None
is internally treated as "no default given". Instead you can set Integer(optional=True)
and then check later on if the value of the parameter is None.
Last updated