Skip to content

sadaszewski/cpython-pipeline-syntax

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

123,884 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(**_)

About

The Python programming language

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 63.1%
  • C 34.8%
  • C++ 0.8%
  • M4 0.4%
  • HTML 0.4%
  • Batchfile 0.1%
  • Other 0.4%