Skip to content

step(function, *args, **kwargs)

Represent a callable with preconfigured arguments.

The wrapped callable is invoked with a value as its first argument, followed by the stored positional and keyword arguments.

The default property provides the initial value used by operations such as step * n and step > file.

Args:
function: The callable to execute.
args: Positional arguments passed to function.
kwargs: Keyword arguments passed to function.

Raises:
TypeError: If function is not callable.

Execution

__call__(default=_DEFAULT)

Execute the step with an input value.

If default is omitted, the step's configured default value is used.

Args:
default: The value passed to the wrapped callable. If omitted, use the
step's configured default.

Returns:
The value returned by the wrapped callable.

Configuration

default property writable

The initial value used when a step operation needs one.

Export

export()

Export the step in pipeline step format.

The returned tuple contains the wrapped callable and, when configured, its positional and keyword arguments.

Returns:
tuple: One of the following forms:

(function,)
(function, args)
(function, kwargs)
(function, args, kwargs)

Operators

__ror__(other)

Execute the step with other as the input value.

Returns:
The value returned by the wrapped callable.

__mul__(other)

Execute the step repeatedly using the previous result as input.

Args:
other: The number of times to execute the step.

Returns:
The value returned by the final execution.

Raises:
ValueError: If other is less than 1.

__lt__(other)

Read a value from a file-like object and execute the step with it.

Args:
other: An object providing a read() method.

Returns:
The value returned by the wrapped callable.

__gt__(other)

Execute the step and write its result to a file-like object.

Args:
other: An object providing a write() method.

Returns:
The value returned by other.write().

Comparison

__eq__(other)

Compare the step with another step or an exported step tuple.

Two steps are equal when they wrap the same callable and have equal positional and keyword arguments.

A step is also equal to its exported tuple representation.

Args:
other: A step instance or an exported step tuple.

Returns:
True if the objects represent the same step, False if they do not, or NotImplemented for unsupported types.