Skip to content

chain(steps, default=None)

Execute callables and pipeline steps sequentially with an initial value.

Each step receives the result of the previous step as its first positional argument.
A callable is called with only that value.
A step tuple may be (function,), (function, args), (function, kwargs), or (function, args, kwargs).
When keyword arguments are supplied, positional arguments must be a tuple.

Args:
steps: An iterable of callables or pipeline step tuples to execute in order.
default: Initial value passed to the first step.
Defaults to None.

Returns:
The result produced by the last step, or default if no steps are configured.

Raises:
TypeError: If a non-callable step has an invalid format.