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
Close
Hashes for dialogue.multi-method-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53d3b4ea12e8830f71fca944ef942f33481a7520f7fb4742fbabb900aecfab8f |
|
MD5 | ba9b5da25366b3a4e0ac5cbe32a35900 |
|
BLAKE2b-256 | 691efeed550870748fcdb05fbb6147a3a8d92cf04b38c274e37cacb94228c435 |