partial-apply
Partial application of functions and method names, supporting placeholder values for positional arguments.
Unlike functools.partial(), placeholder values are supported so that positional arguments for partial application do not need to be supplied solely from left to right. Keyword arguments are handled equivalently to functools.partial(). It is also possible to “partially apply” a method name, producing a function which looks up the method to call on the object supplied as its first argument.
Dependencies:
Python 2.7 or 3.4+.
Installation:
$ pip install partial-apply
Documentation:
Sphinx generated API documentation is available in the docs subdirectory of this repository and is also published on GitHub Pages.
Examples
An example of placeholder use:
from partial_apply import Empty, PartialFn, PartialMethod
isint = PartialFn(isinstance, Empty, int)
This makes a function isint() that takes one positional argument and returns True if it is an int and False otherwise. That is, calling isint(1) is equivalent to calling isinstance(1, int). The supplied positional arguments fill in Empty placeholder slots from left to right before reverting to functools.partial()-style appending.
An example of PartialMethod use:
count_true = PartialMethod('count', True)
count_true((False, True)) # returns 1
count_true([False, True]) # returns 1
This makes a function count_true() that counts the number of True values in a sequence. It looks up the sequence method count on the first argument and calls it with the single argument True. The calls shown are equivalent to (False, True).count(True) and [False, True].count(True). Since count_true() only stores the method name and not the method itself, it works on any type with a count() method.
Like PartialFn, PartialMethod supports placeholder positional arguments and functools.partial()-like keyword arguments.
Metadata
Release files for partial-apply 1.0.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 |
|---|---|---|---|---|
| partial-apply-1.0.0.tar.gz | 4.5 kB | Without provenance | Details for partial-apply-1.0.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| partial_apply-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for partial_apply-1.0.0-py3-none-any.whl |
| partial_apply-1.0.0-py2-none-any.whl | Python 2 | none | any | Details for partial_apply-1.0.0-py2-none-any.whl |
Total release size: 15.0 kB
Release files / partial-apply-1.0.0.tar.gz
| Download URL | partial-apply-1.0.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1241f8c2789f8e01c6171471f19f8bf77fb553ae363d63dabb13c9a4ba286bec
|
|
BLAKE2b-256 checksum How to use checksums |
db8d0b978badb6e725ce8c0a2c8f6b87fbe4f04668a9b14f5310fc3e44469f11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / partial_apply-1.0.0-py3-none-any.whl
| Download URL | partial_apply-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34fde581a8380f025b6386cc15cbb8c3c47c718e88b6312765da6a2ca6c0430d
|
|
BLAKE2b-256 checksum How to use checksums |
1fb6ac0316759271f12cf88dce3a667af6a78643646e6d462d753cf0ba311d8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / partial_apply-1.0.0-py2-none-any.whl
| Download URL | partial_apply-1.0.0-py2-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
477f8b6d8a4019e0b293be72df97225901fe55d8fffc6997ac465f856f0c9444
|
|
BLAKE2b-256 checksum How to use checksums |
78dfd8bed299f6a8d0198e22f10cec0f18a9dfa20ba845b0a160c4933013ad4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for partial-apply 1.0.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.