This repository holds a pipeline expression implementation for Python.
See: here for Pyodide-based demonstration directly in the browser.
See: here for the PEP document.
The syntax is the following:
[1, 2, 3] |> map(str) |> ", ".join() |> _.split()The _ plays again its role of a soft keyword here and acts as a placeholder to indicate where to insert the results of the LHS into the RHS. If no placeholder is placed, the LHS is injected as the LAST argument. This plays better with existing Python functions. The RHS must be a call.
Can pass the placeholder by position:
5 |> range(1, _) |> list()1 |> range(_, 5) |> list()Or keyword:
5 |> sum([1, 2, 3, 4, 5], start=_)Only one placeholder is allowed, since everything happens on the stack!
Support for star arguments:
[[1,2,3],[4,5,6]] |> zip(*_) |> list()Support for keyword arguments:
{'a': 1, 'b': 2, 'c': 3} |> "{a} {b} {c}".format(**_)