【问题标题】:python signature of method in diamond derived class钻石派生类中方法的python签名
【发布时间】:2015-08-13 08:53:38
【问题描述】:

我想知道从两个具有共同但不同方法的类派生的类中的签名是什么。

例如

class Base1():
    def __init__(a, b):
        self.a = a
        self.b = b

class Base2():
    def __init__(c):
        self.c = c

class Derived(Base1, Base2):

    def do_something():
        return 3

init 方法的签名是什么Derived 类? 它的实现方式是什么?

【问题讨论】:

    标签: python class multiple-inheritance


    【解决方案1】:

    不会有新的签名。相反,将使用方法解析顺序中的第一个方法。在你的情况下是Base1.__init__。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 2021-07-18
      • 2011-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多