A more fine-grained functools.singledispatch
Project description
Like functools.singledispatch, but will allow to register multiple functions for each class.
If a registered function decides it cannot handle the value after inspecting it, it can give up and let others try their luck:
from allot import allot, Pass
@allot
def f(obj):
return 'object'
@f.register(int)
def f_small_integer(obj):
if obj > 10:
return Pass
return 'small integer'
assert f('a string') == 'object'
assert f(3) == 'small integer'
assert f(10) == 'object'
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 Distribution
allot-0.2.tar.gz
(18.3 kB
view details)
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
allot-0.2-py3-none-any.whl
(38.8 kB
view details)
File details
Details for the file allot-0.2.tar.gz.
File metadata
- Download URL: allot-0.2.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.21.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e607c8860705a5cdc6bbd523470840e938ca5e1f1ac4daac64974483994433b6
|
|
| MD5 |
360e351827afb525506210c1b7460f55
|
|
| BLAKE2b-256 |
3388a0a075c987fba56a00fdb6f14e05278d78954b3fd0689a24c11bd3b8b555
|
File details
Details for the file allot-0.2-py3-none-any.whl.
File metadata
- Download URL: allot-0.2-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.21.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8393ea1257abceb4399ea398dad4385317f06647004617c6a42ea315ed127e3
|
|
| MD5 |
621cbd3a9e482e4874cd469f2d433ab7
|
|
| BLAKE2b-256 |
28605624bc69d5abae599c79d8a019f7e94fdbaa4cb893b5c45308fb44bd99a3
|