BaseServer::self.process_request(request, client_address)
实现原理:
在类的继承关系中,当子类中没有相应的方法时就会去父类中寻找,
当继承多个父类时,子类没有的,依继承顺序,在父类中由左到右依次查询
测试:
子类和父类同时拥有该方法
#coding:UTF-8 class A: #def __init__(self): #print ("A __init__") def fun(self): print ("A fun") class B: def __init__(self, a,b): print (a,b) self.fun() def fun(self): print ("B fun1") class C(A, B): pass def fun(self): print ("C fun") if __name__ == "__main__": c = C(1,2)
>>>> 1,2
>>>> C fun
子类没有该方法而父类拥有
#coding:UTF-8 class A: #def __init__(self): #print ("A __init__") def fun(self): print ("A fun") class B: def __init__(self, a,b): print (a,b) self.fun() def fun(self): print ("B fun1") class C(A, B): pass #def fun(self): #print ("C fun") if __name__ == "__main__": c = C(1,2)
>>>> 1,2
>>>> A fun