import poser, toolz
https://toolz.readthedocs.io/en/latest/composition.html
Be a poser
How is functional programming like legos. https://toolz.readthedocs.io/en/latest/composition.html#lego
poser is a API for lazy, (dys)functional python programming. It allows complex functions to be composed using fluent or symbollic interfaces.
pip install poser
dysfunctional programming === Functional programming with all the side effects.
New to [functional programming]? Functional programming uses declarative functions to compose complex operations on arguments.
If you are familiar with python then [toolz][toolz] is a great starting point, [poser][poser] is a compact [API] for [toolz] and the python
[standard library].
poser
poser API
from poser import λ, Λ, stars
λ is a composition that always returns a function. For example, below we create a list of numbers from 1 to a some value
>>> f = λ.range(1).list(); f
λ(<class 'list'>, functools.partial(<class 'range'>, 1))
>>> assert callable(f)
>>> f(5), f(10)
([1, 2, 3, 4], [1, 2, 3, 4, 5, 6, 7, 8, 9])
poser can use forward references to lazily import modules.
>>> g = λ.range(1).enumerate().dict()['pandas.Series']; g
λ(ForwardRef('pandas.Series'), <class 'dict'>, <class 'enumerate'>, functools.partial(<class 'range'>, 1))
>>> λ(9) + g + type + ...
<class 'pandas.core.series.Series'>
Λ is for object function composition where the
function represents symbollic or chained methods
>>> (Λ*10+2)(1)
12
>>> assert (Λ*10+2)(1) == 1*10+2
>>> s = "A formatted string :{}: with a %s"
... (Λ.format('foo') % '% formatted').upper()(s)
'A FORMATTED STRING :FOO: WITH A % FORMATTED'
>>> assert (Λ.format('foo') % '% formatted').upper()(s)\
... == (s.format('foo') % '% formatted').upper()
The poser API expresses all of the symbols in the python data model. Refer to the tests for examples.
juxtaposition
>>> assert isinstance(λ[range, type, str](10), tuple)
>>> assert isinstance(λ[[range, type, str]](10), list)
>>> assert isinstance(λ[{range, type, str}](10), set)
Value and keyword functions can be supplied to juxtapose functions across dictionaries.
λ[{'a': range, type: str}](10)
{'a': range(0, 10), int: '10'}
Example recipes.
get = λ['functools.lru_cache']()(λ['requests.get'][λ[Λ.json()] ^ BaseException | Λ.text()]); get
read = λ**Λ.startswith('http') & get | λ.Path().read_text()
Metadata
Release files for poser 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| poser-0.2.3.tar.gz | 29.2 kB | Without provenance | Details for poser-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| poser-0.2.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for poser-0.2.3-py2.py3-none-any.whl |
Total release size: 38.9 kB
Release files / poser-0.2.3.tar.gz
| Download URL | poser-0.2.3.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b573169b8f94aa14dc6c88acbd615cd6ab49058d8095d55f590ea8805a77db3
|
|
BLAKE2b-256 checksum How to use checksums |
e876b3742c8733ecd08edf867d538741979451aa2be3e15811881e7d188518b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Release files / poser-0.2.3-py2.py3-none-any.whl
| Download URL | poser-0.2.3-py2.py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b882af41fba29eb22dabd5e6cc6671a2ce80c67f128a72fe3c0b15cba2283aee
|
|
BLAKE2b-256 checksum How to use checksums |
b82236ccfd8e5bd04dcb4d84bbf02fde8f142a41bd69e9188a54914e265a85d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Security for poser 0.2.3
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.