Added simple user guide in README.
This commit is contained in:
parent
caf5987cb9
commit
ab854e9fdd
30
README.rst
30
README.rst
@ -1,5 +1,5 @@
|
||||
Generic -- programming library for Python
|
||||
=========================================
|
||||
Generic programming library for Python
|
||||
======================================
|
||||
|
||||
Generic is trying to be simple and easy-to-use programming library that
|
||||
features the following:
|
||||
@ -10,3 +10,29 @@ features the following:
|
||||
* Event system (not implemented).
|
||||
|
||||
Its development takes place at http://githib.com/andreypopp.
|
||||
|
||||
Multidispatching
|
||||
----------------
|
||||
|
||||
Generic library provides way to define function with multidispatching feature::
|
||||
|
||||
from generic.multidispatching import multifunction
|
||||
|
||||
@multifunction(int, int)
|
||||
def add(x, y):
|
||||
return x + y
|
||||
|
||||
@add.when(str, str)
|
||||
def add(x, y):
|
||||
return add(int(x), int(y))
|
||||
|
||||
And then in console::
|
||||
|
||||
>>> add(1, 2)
|
||||
3
|
||||
>>> add("1", "2")
|
||||
3
|
||||
>>> add("1", 2)
|
||||
Traceback
|
||||
...
|
||||
TypeError: ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user