我在确定使“子类”在其子类中调用函数的最佳方法时遇到了一些问题
设计看起来像这样:
class BaseA():
a_attr = 'I handle Table'
def entery_point(self):
print('Computing Value from %s' % self.a_attr)
for child in self._children: #filling the self._children is where i think need help
child().entery_point_b()
class BaseB(A):
b_attr = 'I handle Fields'
def entery_point_b(self):
print('Computing Value from %s and %s' % (self.a_attr,self.b_attr) )
#Now the concrete classes
class A(BaseA):
a_attr = 'table_name'
class B(BaseB,A):
b_attr = 'field_name_1'
class BB(BaseB, A):
b_attr = 'field_name_2'
#another set of concrete classes to handle another table
class A2(BaseA):
a_attr = 'another_table_name'
class B2(BaseB,A2