Skip to main content

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

def f(obj):
    return 'object'

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for allot, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size allot-0.2-py3-none-any.whl (38.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size allot-0.2.tar.gz (18.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page