set_defaults#
- tpcp.misc.set_defaults(**defaults)[source]#
Set the default values of a function.
This will return a wrapped version of the function, that has the default values set. This might be useful, if you want to set default values programmatically (i.e. load them from a file).
This decorator also works on class methods, and might be used to set default values of class-init parameters.
- Parameters:
- **defaults
The new default values for the function’s parameters. Note, that this must be a subset of the function’s parameters. Further, you can not set default values for parameters that already have a default value. This will raise a ValueError.
- Returns:
- decorator
A decorator that can be applied to a function to modify its default values.