【发布时间】:2014-04-28 20:14:38
【问题描述】:
class Parent(object):
def __init__(self, first):
self.first = first
class Child1(Parent):
def __init__(self):
Parent.__init__(self, 'A')
- 我有这个父类,我想创建 12 个类似的继承父类的类,它们都具有相同的签名和无参数。如何使用
type()定义 Child1? 到目前为止我有Child1 = type('Child1', (Rank,), dict())但我怎样才能将first传递给Parent类?
【问题讨论】:
标签: python class inheritance types parameters