dialogue.multi-method
A small library to provide multi-methods. All functions are in the dialogue.multi_method package.
To create a multi-method, create a dispatch function, that takes the arguments and returns a hashable value, that is used to dispatch on. Use the @multi function annotation to annotate the function.
For each value of the dispatch function that you want to be handled differently, create a method with that dispatch value.
You can define a method with no dispatch value, that becomes the default method if no other method is defined for a dispatch value.
An example:
@multi def number(x): return x @method(number, 1) def number_one(x): return 'one' @method(number) def number_other(x): return "not one, but "+ str(c) assert number(1) == 'one' assert number(0) == 'not one, but 0'
The dispatch function is available, e.g. for testing:
assert dispatch_fn(number)('x') == 'x'
Metadata
Release files for dialogue.multi-method 0.0.5
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 |
|---|---|---|---|---|
| dialogue.multi-method-0.0.5.tar.gz | 2.5 kB | Without provenance | Details for dialogue.multi-method-0.0.5.tar.gz |
Release files / dialogue.multi-method-0.0.5.tar.gz
| Download URL | dialogue.multi-method-0.0.5.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f83adb2802c327514d1ad3fdb32cfefcc0818ba1e6281a35b595254caa21473
|
|
BLAKE2b-256 checksum How to use checksums |
8d591dc742320c5dc21abac38553deb11b34482e2c7779dbb30ab05dc5de8167
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.9.1 pkginfo/1.4.1 requests/2.18.3 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.1
|
Security for dialogue.multi-method 0.0.5
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.