将接口引入python。
python-interfaces的Python项目详细描述
python接口
安装
pip install python-interfaces
用法
from interface import interface
class Iterable:
def be_iterable(self):
pass
@interface(Iterable)
class Foo:
def __init__(self):
pass
# raises InterfaceException
地方发展
git clone https://github.com/tyleragreen/python-interfaces.git && cd python-interfaces
virtualenv ~/.env/interface
source ~/.env/interface/bin/activate
pip install -r requirements_dev.txt
# Since the tests live outside the package, we install the package in editable mode
pip install -e .
py.test
其他想法
- 支持dunder方法
- 强制方法signatures
- 要求接口方法为空/抽象/
pass
-仅