Multiple dispatcher on arguments values.
Project description
# dispatk
## Description
This function is inspired by singledispatch of Python 3.4+ (PEP 443),
but the dispatch happens on the key extracted fro the arguments values.
```
from dispatk import dispatk
@dispatk(lambda n: int(n))
def fib(n):
return fib(n-1) + fib(n-2)
@fib.register(0)
def _(n):
return 0
@fib.register(1, 2)
def _(n):
return 1
@fib.register(41)
def _(n):
return 165580141
```
*register* accepts one or more keys, so
```
@fib.register(1, 2)
def _(n):
return 1
```
is equivalent to
```
@fib.register(1)
@fib.register(2)
def _(n):
return 1
```
## Description
This function is inspired by singledispatch of Python 3.4+ (PEP 443),
but the dispatch happens on the key extracted fro the arguments values.
```
from dispatk import dispatk
@dispatk(lambda n: int(n))
def fib(n):
return fib(n-1) + fib(n-2)
@fib.register(0)
def _(n):
return 0
@fib.register(1, 2)
def _(n):
return 1
@fib.register(41)
def _(n):
return 165580141
```
*register* accepts one or more keys, so
```
@fib.register(1, 2)
def _(n):
return 1
```
is equivalent to
```
@fib.register(1)
@fib.register(2)
def _(n):
return 1
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
dispatk-0.1-py2.7.egg
(3.4 kB
view details)
File details
Details for the file dispatk-0.1-py2.7.egg.
File metadata
- Download URL: dispatk-0.1-py2.7.egg
- Upload date:
- Size: 3.4 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be4b912cba8cc968c43228a6b58ae88896b4afa703e03165b62ec55e4a2cbedf
|
|
| MD5 |
d8676cdcc89cd54bd2e77908fb239abc
|
|
| BLAKE2b-256 |
d47b24e24ed021a09e61826057bc56013fb1a4532bc883851e36b4531f8f4ab4
|