Multiple dispatch in Python
Project description
Plum: Multiple Dispatch in Python
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
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
plum-dispatch-1.7.3.tar.gz
(56.4 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
File details
Details for the file plum-dispatch-1.7.3.tar.gz.
File metadata
- Download URL: plum-dispatch-1.7.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42c83c1f3f3e7fb9ef6f174637f20167f6d0570f165a09113eed971a39257775
|
|
| MD5 |
2f1ecf99e0aaeea34ace78af19137991
|
|
| BLAKE2b-256 |
de4b18621302f4aa282ef678fd5a185fce5815c3dc5cab598cfb1b528013abbe
|
File details
Details for the file plum_dispatch-1.7.3-py3-none-any.whl.
File metadata
- Download URL: plum_dispatch-1.7.3-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9e93764ee57145f65984a7807d884fa32d5500035c8437146893ca7a19de7fa
|
|
| MD5 |
df406b6b896cff134d02239cda2458b8
|
|
| BLAKE2b-256 |
a178e4d5e0d0ac95905fc14d8a6a0d00b79f0c0fea3c1af474ebe3605cd013aa
|