我正在尝试使用 S.Lott 的响应构建策略模式。
问题是函数返回无。
我正在使用 Hickey 的 Simple vs Easy {what, how, who}-逻辑。
-[什么] I/O
class base_fnc(object):
def fncExc(self,data1,data2):
return
-[HOW] DATA <> queue[where,when](直接注入)
class stump( base_fnc ):
def fncExc(self, d1, aContext):
return d1
class MAB(base_fnc ):
def fncExc(self, d, aContext ):
return d+10
-[世界卫生组织] API
class context( object ):
def __init__(self, alt_how_class ):
self.how = alt_how_class
def exc(self, d ):
return self.how.fncExc(d, self)
if __name__ == "__main__":
c1 = context(MAB())
ss=c1.exc(10)
print ss
ss 打印无