aspis.common.apply
- aspis.common.apply(func, *args, **kwargs)[source]
Alias for functools.partial - partial function application.
Partially applies arguments to a function, returning a new function with those arguments fixed. This is an alias for Python’s built-in functools.partial.
- Parameters:
func (Callable) – The function to partially apply.
*args – Positional arguments to fix.
**kwargs – Keyword arguments to fix.
- Returns:
A new function with the given arguments partially applied.
- Return type:
Callable
Example
>>> def greet(greeting, name): ... return f"{greeting}, {name}!" >>> say_hello = apply(greet, "Hello") >>> say_hello("Alice") 'Hello, Alice!' >>> say_hello("Bob") 'Hello, Bob!'