set_defaults#

tpcp.misc.set_defaults(**defaults: Unpack) Callable[[Callable[[P], R]], Callable[[P], R]][source]#

Set the default values of a function’s parameters.

This decorator returns a wrapped version of the function, with the specified default values set. This can be useful when you want to set default values programmatically, such as loading them from a file.

This decorator also works on class methods, and can be used to set default values of class initialization parameters.

Note that the new default values must be a subset of the function’s parameters. Also, you cannot set default values for parameters that already have a default value. Doing so will raise a ValueError.

Parameters:
**defaults

The new default values for the function’s parameters.

Returns:
decorator

A decorator that can be applied to a function to modify its default values.