Skip to main content

Multiple dispatch in Python

Project description

Plum: Multiple Dispatch in Python

DOI CI Coverage Status Latest Docs Code style: black

Everybody likes multiple dispatch, just like everybody likes plums.

Installation

Plum requires Python 3.7 or higher.

pip install plum-dispatch

Documentation

See here.

What's This?

Plum brings your type annotations to life:

from numbers import Number

from plum import dispatch

@dispatch
def f(x: str):
    return "This is a string!"


@dispatch
def f(x: int):
    return "This is an integer!"


@dispatch
def f(x: Number):
    return "This is a general number, but I don't know which type."
>>> f("1")
'This is a string!'

>>> f(1)
'This is an integer!'

>>> f(1.0)
"This is a number, but I don't know which type."

>>> f(object())
NotFoundLookupError: For function "f", signature Signature(builtins.object) could not be resolved.

Project details


Download files

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

Source Distribution

plum-dispatch-1.7.4.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plum_dispatch-1.7.4-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file plum-dispatch-1.7.4.tar.gz.

File metadata

  • Download URL: plum-dispatch-1.7.4.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for plum-dispatch-1.7.4.tar.gz
Algorithm Hash digest
SHA256 1c1d15b2842b5fa98405fd3dff6fad4887bdc77b60bd200e209d76ebfe9990fe
MD5 0c61bf07fe3c9d50255170dc932e9b45
BLAKE2b-256 394ef4d6b2bd80a9880989d37773f0f2e3a91a2d5352732e4ebb68b5606bca83

See more details on using hashes here.

File details

Details for the file plum_dispatch-1.7.4-py3-none-any.whl.

File metadata

  • Download URL: plum_dispatch-1.7.4-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for plum_dispatch-1.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c40dbeab269bbbf972ce0dbc078380da19ebaee1a370a2c564e1814a11bde216
MD5 0ea7fdfccbc81cae8eb84c9c7b2d37df
BLAKE2b-256 e6b63aaa985591c63da64c7bd8c5f470442a4c00b37ad3ed057f21de14174f83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page