相关疑难解决方法(0)

Python多重继承:在所有上调用super

我有以下两个超类:

class Parent1(object):
    def on_start(self):
        print('do something')

class Parent2(object):
    def on_start(self):
        print('do something else')
Run Code Online (Sandbox Code Playgroud)

我希望有一个继承的子类可以为父母双方打电话.

class Child(Parent1, Parent2):
    def on_start(self):
        # super call on both parents
Run Code Online (Sandbox Code Playgroud)

什么是Pythonic的方法呢?谢谢.

python

10
推荐指数
1
解决办法
3562
查看次数

标签 统计

python ×1