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 when an operation does not supply an input value.
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)
Representation
__iter__()
Iterate over the exported step components.
This allows the step to be unpacked using tuple unpacking syntax, such as function, args, kwargs = my_step.
__repr__()
Return a readable representation of the step.
The representation includes the wrapped callable name and its configured positional and keyword arguments.
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, or NotImplemented if other is not an integer.
Raises:
ValueError: If other is less than 1.
__pow__(other)
Create multiple copies of the step.
Args:
other: The number of step instances to create.
Returns:
A list containing the created step instances, or NotImplemented if other is not an integer.
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.