Skip to main content

No project description provided

Project description

A small library to provide multi-methods. All functions are in the dialogue.multi_method package.

To create a multi-method, create a dispatch function, that takes the arguments and returns a hashable value, that is used to dispatch on. Use the @multi function annotation to annotate the function.

For each value of the dispatch function that you want to be handled differently, create a

An example:

@multi
def number(x):
  return x


@method(number, 1)
def number_one(x):
  return ''one'


@method(number)
def number_other(x):
  return "not one, but "+ str(c)


assert number(1) == 'one'
assert number(0) == 'not one, but 0'

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

dialogue.multi-method-0.0.1.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file dialogue.multi-method-0.0.1.tar.gz.

File metadata

File hashes

Hashes for dialogue.multi-method-0.0.1.tar.gz
Algorithm Hash digest
SHA256 df830d1293e9654a6f9718803f525c2eb9aaf5cdb02b0f3b77dbdc39b117f98c
MD5 aa905e6ca16a6d4421bea3a5730a27c9
BLAKE2b-256 75b585fe8d2d80330f91cba257c7fd4777581dc63c166ae26a3f9795848a5d29

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