spread()
Create a function that spreads an array argument to func as individual arguments.
Implementation
Args: func: The function to spread arguments to Returns: A function that spreads array arguments
Example
def add_three(a, b, c):
return a + b + c
spread_add = spread(add_three)
spread_add([1, 2, 3])
Expected output: 6
Source Code
def spread(func: Callable) -> Callable:
_validate_callable(func)
def wrapper(args_array, **kwargs):
return func(*args_array, **kwargs)
return _copy_function_metadata(wrapper, func)