Skip to main content

TypeDispatch is a Python utility for registering and dispatching functions based on object types, supporting inheritance through method resolution order (MRO).

Project description

typedispatch

typedispatch is a Python library for registering functions based on type resolution. It allows you to associate types with functions and dynamically look up functions based on the type of an object, including handling inheritance hierarchies.

Installation

pip install typedispatch

Usage

from typedispatch import TypeDispatch, TypeDispatchError

typedispatch = TypeDispatch()

typedispatch.register(int, lambda x: f"Processing integer: {x}")
print(typedispatch.lookup(10))  # Output: Processing integer: 10

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

typedispatch-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

typedispatch-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file typedispatch-0.1.0.tar.gz.

File metadata

  • Download URL: typedispatch-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for typedispatch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 628f36b5c5f66f2480942a5b1be71b30f95b992c8a4d77ba82f7ea8590d9f576
MD5 af6f6779cedda43df113a6235cba2d6d
BLAKE2b-256 d7996da1cf008d1422a9fabc44b6070a6fb74f9a10bbdd6de144a192d2077541

See more details on using hashes here.

File details

Details for the file typedispatch-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for typedispatch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e13c25ddc0b5c12cfdb81a0b0ae9441dad9ef73a34eaaaf285c1f39901d005
MD5 dab835a73a4a9c71e4911e7853c984a8
BLAKE2b-256 490cffe1c3088fef9040d950d7bdcb095319698e55412e2a5669368b5992e8a7

See more details on using hashes here.

Supported by

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