ベースに変数を使用する必要があるため、型を持つクラスを作成します。メソッドを提供しなくても問題なく動作しますが、__init__
メソッドを提供すると、ベースの を呼び出すことができません__init__
。
作品:
def constructor():
blah blah
api = importlib.import_module(xtype)
mc = type('mc', (api.aclass,), {})
obj = mv(**args)
return obj
動作しません。" SystemError: super(): __class__ cell not found
"を返します
def constructor():
blah blah
api = importlib.import_module(xtype)
mc = type('mc', (api.aclass,), dict(__init__ = mc__init)
obj = mc(**args)
return obj
def mc_init(*args, **kwargs):
do_some_stuff
super().__init__(*args, **kwargs)
は機能せず、Base mc.__init__ not called.
後でオブジェクト作成時に " " を返します:
def constructor():
global api
blah blah
api = importlib.import_module(xtype)
mc = type('mc', (api.aclass,), dict(__init__ = mc__init)
obj = mc(**args)
return obj
def mc_init(*args, **kwargs):
global api
do_some_stuff
api.aclass.__init__(*args, **kwargs)
x = constructor()
基本クラスのinitを呼び出すにはどうすればよいですか?
ありがとう。