Install
pip install pipe-fn
pipe-fn
Function transformation purely.
from pipe_fn import e
# e is the identity mapping
def add(this, other):
return this + other
print([1, 2, 3] | e / sum)
# sum([1, 2, 3])
# => 6
print([2, 3, -1] | e ** {'key': lambda x: -x} / sorted) # set kwargs
# sorted([2, 3, -1], key=lambda x: -x)
# => [3, 2, -1]
print([[1], [2], [3]] | e / sum * ([],)) # set args
# sum([[1], [2], [3]], [])
# => [1, 2, 3]
def my_func(self, *args, **kwargs):
return self, args, kwargs
print([1, 2, 3]
| e
** dict(a=1, b=2, c=3) # you should set kwargs first because of the high priority of `**` operator.
* (4, 5, 6) # it'okay to change the order of setting `args` and setting `function`.
/ my_func)
# => ([1, 2, 3], (4, 5, 6), {'a': 1, 'b': 2, 'c': 3})
print(1 | e / add * (1,))
# add(1, 1)
# => 2
def double(x):
return 2 * x
# and then composition
print(1 | (e / add * (2,) + double + double))
# double(double(add(1, 2))
# => 12 = (1 + 2) * 2 * 2
# set single arg
[['a'], ['b']] | e / sum @ [] \
| e / print
# print(sum([['a'], ['b']], []))
# => [1, 2]
def double(x):
return 2 * x
[1, 2, 3] | e / std.general.Sum @ double \
| e / print
# print(Sum([1,2,3], double))
# => 12
Metadata
Release files for pipe-fn 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pipe_fn-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for pipe_fn-0.2.2-py3-none-any.whl |
Release files / pipe_fn-0.2.2-py3-none-any.whl
| Download URL | pipe_fn-0.2.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c9040262d5eb4092d6e16f05f018ac7a9e04a0b3a3d66f709306982b6517971
|
|
BLAKE2b-256 checksum How to use checksums |
ab718497dd8cb9e965ba13ce0c16b5db9a7581b73fffa3e7af5dca113410f389
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pipe-fn 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.