Metadata-Version: 2.1
Name: arg-dispatch
Version: 0.1.3
Summary: function can be dispatched by its arguments
Home-page: https://github.com/zen-xu/arg_dispatch
License: GPL-3.0
Keywords: dispatch
Author: zen-xu
Author-email: zen-xu@outlook.com
Requires-Python: >=3.6,<4.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Project-URL: Repository, https://github.com/zen-xu/arg_dispatch
Description-Content-Type: text/markdown

# arg_dispatch
function can be dispatched by its arguments

## Example
```python
from arg_dispatch import dispatch


# Functions
@dispatch
def demo(a, b):
    return 'hello'
    
@dispatch
def demo(c):
    return 'world'
    

demo(a=1, b=2)  # return 'hello'
demo(c=3)       # return 'world'

# try to call a function which has not been registed
demo(d=4)       # raise `FunctionNotRegist`

# Methods
class Demo(object):
    @dispatch
    def demo(self, a, b):
        return 'hello'
        
    @dispatch
    def demo(self, c):
        return 'world'
        
instance = Demo()
instance.demo(a=1, b=2)  # return 'hello'
instance.demo(c=3)       # return 'world'

# try to call a method which has not been registed
instance.demo(d=4)       # raise `FunctionNotRegist`
```

## Notice💣
**positional arguments must be required**
```python
demo(1, 2)          # Boom!💣, raise `ArgumentError`
instance.demo(1, 2) # Boom!💣, raise `ArgumentError`
```

**default value is also not supported**
```python
@dispatch
def demo(a, b=1):            # Boom!💣, raise `ExistDefaultValue`
    return 'hello'
    
class Demo(object):
    @dispatch
    def demo(self, a, b=1):  # Boom!💣, raise `ExistDefaultValue`
        return 'hello'
```

