MiniOperators for Python
This library makes it almost trivial to add extended operators to the python language, or to transform existing functions into binary operators. For example, one might take the function compose:
def compose(f, g):
return lambda *args, **kwargs: f(g(*args, **kwargs))
And turn it into an operator, |compose|:
compose = MiniOperator(compose)
Then, the operator can be used as a binary operator [1]:
f = math.sqrt |compose| (lambda x: x**2 + 1) f(0) # 1.0
If one consistently uses this |<name>| notation and parenthesises arguments, no problems should arise [2].
Furthermore, the operator thus created will support overriding through the standard Python convention of __<name>__ and __r<name>__ special methods.
Documentation
The MiniOperator constructor can be called in three ways. MiniOperator(f) creates an operator named f that uses f as its default operation [3]. A name can also be explicitely passed: MiniOperator(name, f), where name is a string, will create an operator named name that uses f as a default operation. Finally, one can create an operator without specifying a default method: MiniOperator(name), where name is a string, will result in an operator that will throw a NotImplementedError when used on most arguments. However, a class will be able to explicitely override __<name>__ or __r<name>__ to support this operator.
Footnotes
Metadata
Release files for MiniOperators 1.0
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 |
|---|---|---|---|---|
| MiniOperators-1.0.tar.gz | 14.4 kB | Without provenance | Details for MiniOperators-1.0.tar.gz |
Release files / MiniOperators-1.0.tar.gz
| Download URL | MiniOperators-1.0.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2511620a469931150c431fc1569747ac9886b915563f09eb0a74436f1a52d2f7
|
|
BLAKE2b-256 checksum How to use checksums |
4b505bd63fc95044f86f989b50a91f03933c1f4aa2f47798ae58c1fa7ada1a64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for MiniOperators 1.0
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.