Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我们是否应该;超级();在底层?_Python_Python 3.x_Super_Method Resolution Order - Fatal编程技术网

Python 我们是否应该;超级();在底层?

Python 我们是否应该;超级();在底层?,python,python-3.x,super,method-resolution-order,Python,Python 3.x,Super,Method Resolution Order,在Python 3中,我使用继承类中的super,如下所示: class Orange(Fruit): def __init__(self): super().__init__() 在上面的代码片段中,Orange类继承自Fruit类。看看父类 class Fruit(): def __init__(self): pass # call super().__init__() here? 我们是否需要从父类/基类调用super才能使M

在Python 3中,我使用继承类中的super,如下所示:

class Orange(Fruit):
    def __init__(self):
        super().__init__()
在上面的代码片段中,
Orange
类继承自
Fruit
类。看看父类

class Fruit():
    def __init__(self):
        pass       # call super().__init__() here?

我们是否需要从父类/基类调用super才能使MRO有效工作?

否,在Python中,对基类调用
super
上的
\uuu init\uuu
没有意义,除非使用多重继承,否则MRO仍将正确初始化。