-- flyaflya [2005-08-04 09:26:24]
Contents
定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。
1 class Base: 2 def doAll(self): 3 self.doThis() 4 self.doThat() 5 6 class Foo(Base): 7 def doThis(self): 8 print "do this" 9 def doThat(self): 10 print "do that" 11 12 #测试 13 Foo a 14 a.doAll() 15 #输出 16 #do this 17 #do that
声明
1
使用情景
看例子感觉和接口很像 --HoLin