"""Alias for functools.partial - partial function application."""
from functools import partial as _partial
[docs]
def apply(func, *args, **kwargs):
"""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.
Args:
func (Callable): The function to partially apply.
*args: Positional arguments to fix.
**kwargs: Keyword arguments to fix.
Returns:
Callable: A new function with the given arguments partially applied.
Example:
>>> def greet(greeting, name):
... return f"{greeting}, {name}!"
>>> say_hello = apply(greet, "Hello")
>>> say_hello("Alice")
'Hello, Alice!'
>>> say_hello("Bob")
'Hello, Bob!'
"""
return _partial(func, *args, **kwargs)