Func
func ¶
P = ParamSpec('P') module-attribute ¶
T = TypeVar('T') module-attribute ¶
bind(__func: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> Union[functools.partial, Callable[..., T]] ¶
Bind arguments to a function and return a new function.
This function is similar to functools.partial but it allows to bind arguments by name and by position (converting positional arguments to keyword arguments when possible).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
__func | Callable | The function to bind arguments to. | required |
*args | args | Positional arguments to bind to the function. | () |
**kwargs | kwargs | Keyword arguments to bind to the function. | {} |
Returns:
| Type | Description |
|---|---|
partial or Callable | A new function with the arguments bound. |