Source code for aspis.common.always
from typing import Any, Callable
[docs]
def always(x: Any) -> Callable[[], Any]:
"""
Returns a function that always returns the same value.
Args:
x (Any): The value to be returned by the function.
Returns:
Callable: A function that always returns the value x.
Example:
>>> always_42 = always(42)
>>> always_42()
42
>>> always_42(1, 2, 3)
42
"""
return lambda *_, **__: x