Added properties support Fix MultiDelegated.delegates property Tested with Python 2.7 and 3.6
Added properties support
Python delegate pattern library
Simple implementation of the delegate pattern.
$ pip install delegation
Here’s a basic example:
from delegation import SingleDelegated, MultiDelegated class A(object): def foo(self): return 'A.foo()', self.__class__.__name__ def bar(self): return 'A.bar()', self.__class__.__name__ def xyz(self): return 'A.xyz()', self.__class__.__name__ class B(SingleDelegated): def foo(self): return 'B.foo()', self.__class__.__name__ class C(MultiDelegated): def xyz(self): return 'C.xyz()', self.__class__.__name__ print(B(A()).foo()) # ('B.foo()', 'B') print(B(A()).bar()) # ('A.bar()', 'A') print(B(A()).xyz()) # ('A.xyz()', 'A') print(C(A(), B(A())).foo()) # [('A.foo()', 'A'), ('B.foo()', 'B')] print(C(A(), B(A())).bar()) # [('A.bar()', 'A'), ('A.bar()', 'A')] print(C(A(), B(A())).xyz()) # ('C.xyz()', 'C')
BSD
面向对象方法委托与分发辅助工具,用于软件开发和接口组织。
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
delegation v.1.1
Python delegate pattern library
About
Simple implementation of the delegate pattern.
Installation
Examples
Here’s a basic example:
License
BSD