我正在与 cantera 合作,试图cantera.Solution
通过创建 subclass 来创建类的扩展Flow
。这基本上是用它的运动参数来扩展对气相的描述。
Solution
是通过使用某些构造的**kwargs
。我想要做的是将它们保存**kwargs
在一个Template
类对象中并使用该对象来定义我Flow
的对象。我试图Solution.__init__
使用. Flow.__init__
_ 但是,似乎覆盖了.Template
super()
Solution.__init__
Flow.__init__
class Flow(Solution):
def __init__(self, template, velocity):
super().__init__(species = template.species,
reactions = template.reactions,
thermo = template.thermo,
kinetics = 'GasKinetics')
self.velocity = velocity
现在,假设我有一个Template
名为 的适当对象template
,它用作所有**kwargs
所需对象的容器Solution.__init__
。我正在尝试创建我的Flow
对象:
flow = Flow(template, 230)
我得到:
AttributeError: 'Template' object has no attribute 'encode'
如果我尝试,我会得到同样的错误:
S = Solution(template, 230)
所以基本上我所有的子类构造函数参数都传递给超类的构造函数。由于未覆盖超类构造函数,因此我不能使用Template
对象将 my 定义Solution
为Flow
. 我在网上读到这不是默认行为,因为子类构造函数应该覆盖超类构造函数。这有什么帮助?