datadispatch
datadispatch provides a dispatch mechanism (a.k.a. polymorphism) like functools.singledispatch, but it operates on data instead of types. This is useful if you are creating simple data-centric applications where you want polymorphism à la carte without resorting to types or classes.
datadispatch is available through pip: pip install datadispatch
Usage example
from datadispatch import datadispatch
@datadispatch(lambda args, _: args[0].get('type'))
def handle(message):
raise ValueError('cannot handle message: {}'.format(message))
@handle.register('ping')
def _(message):
return 'you sent ping'
@handle.register('pong')
def _(message):
return 'you sent pong'
print(handle(
{'type': 'ping', 'payload': 'hello'}
))
Metadata
Release files for datadispatch 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 | |
|---|---|---|---|---|
| datadispatch-1.0.0.tar.gz | 1.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| datadispatch-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.4 kB
Release files / datadispatch-1.0.0.tar.gz
| Download URL | datadispatch-1.0.0.tar.gz |
|---|---|
| Size | 1.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c0456934e99f21137332deebbda05713dc07fcb142dfc01ef83d6b17aeaf08e
|
|
BLAKE2b-256 checksum How to use checksums |
afc92a1d98bf6a1e2ca41465dd77dc025d8a13b713c6d4378227c8938258c5d4
|
| 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.6.6
|
Release files / datadispatch-1.0.0-py3-none-any.whl
| Download URL | datadispatch-1.0.0-py3-none-any.whl |
|---|---|
| Size | 2.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
527ad534881d7f6144a8ff643c260a3d2ae0d50e8ee24ec4b0fdae72d6c7beab
|
|
BLAKE2b-256 checksum How to use checksums |
806ad38daeb232e560803057c202ada249c5f53a7d532eae216660af42a23781
|
| 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.6.6
|
Security for datadispatch 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.