Skip to main content

arg_dispatch

function can be dispatched by its arguments

Example

from arg_dispatch import dispatch


# Functions
@dispatch
def demo(a, b):
    return 'hello'
    
@dispatch
def demo(c):
    return 'world'
    

demo(a=1, b=2)  # return 'hello'
demo(c=3)       # return 'world'

# try to call a function which has not been registed
demo(d=4)       # raise `FunctionNotRegist`

# Methods
class Demo(object):
    @dispatch
    def demo(self, a, b):
        return 'hello'
        
    @dispatch
    def demo(self, c):
        return 'world'
        
instance = Demo()
instance.demo(a=1, b=2)  # return 'hello'
instance.demo(c=3)       # return 'world'

# try to call a method which has not been registed
instance.demo(d=4)       # raise `FunctionNotRegist`

Notice💣

positional arguments must be required

demo(1, 2)          # Boom!💣, raise `ArgumentError`
instance.demo(1, 2) # Boom!💣, raise `ArgumentError`

default value is also not supported

@dispatch
def demo(a, b=1):            # Boom!💣, raise `ExistDefaultValue`
    return 'hello'
    
class Demo(object):
    @dispatch
    def demo(self, a, b=1):  # Boom!💣, raise `ExistDefaultValue`
        return 'hello'

Metadata

Release files for arg-dispatch 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arg-dispatch 0.1.3
File Size Uploaded Provenance Actions
arg_dispatch-0.1.3.tar.gz 14.9 kB Without provenance Details for arg_dispatch-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for arg-dispatch 0.1.3
File Interpreter ABI Platform Actions
arg_dispatch-0.1.3-py3-none-any.whl Python 3 none any Details for arg_dispatch-0.1.3-py3-none-any.whl

Total release size: 30.3 kB

Release files / arg_dispatch-0.1.3.tar.gz

Download URL arg_dispatch-0.1.3.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
af1450b39935788eb494fed963c05fd43b4fb8254feffd15c7b8af31fa8f5a01
BLAKE2b-256 checksum
How to use checksums
c38e753b85f970403f650fab1f5046fbef92a6a0f7ed09edac9845a08ff24234
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.6.6 Darwin/18.6.0

Release files / arg_dispatch-0.1.3-py3-none-any.whl

Download URL arg_dispatch-0.1.3-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad8125affea7ac7a118913ede1fed11d6c596d3eac7b99051040d50e0ccab7c9
BLAKE2b-256 checksum
How to use checksums
03cffd6a9adf5de3da5b579b582759adedf77574bc753eab3b58ef06aad81b87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.6.6 Darwin/18.6.0

Security for arg-dispatch 0.1.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page