Linked Questions
156 questions linked to/from How does Python's super() work with multiple inheritance?
5
votes
1
answer
2k
views
multiple inheritance in python with super [duplicate]
class Parent1(object):
def foo(self):
print "P1 foo"
def bar(self):
print "P1 bar"
class Parent2(object):
def foo(self):
print "P2 foo"
def bar(self):
...
3
votes
1
answer
1k
views
In Python why is calling super() function for a class with no superclass defined is not an error? [duplicate]
For a Python novice, please can someone tell me what is happening here? Why is it printing "A init"?
If i remove the line super().__init__() from __init__ function of class B then the behaviour is ...
0
votes
1
answer
1k
views
useless super in multiple inheritance? [duplicate]
in multiple inheritance how super() works?
for example here I have Two init and I want to send args by super():
class LivingThings(object):
def __init__(self, age ,name):
self.name=name
...
1
vote
1
answer
953
views
the searching order of inheritance in python [duplicate]
when searching for attributes, Python looks in object g 1st. If I number each class named in the drawing below (2=2nd, 3=3rd, etc.) Could anyone show me the order in which all these classes are ...
1
vote
1
answer
1k
views
Does order of class bases in python matter? [duplicate]
Is there a (meaningful) difference the two classes below?
class A(Foo, Bar):
...
vs
class B(Bar, Foo):
...
0
votes
1
answer
1k
views
Inheriting form two classes in python with super. can you call parent init methods with super()? [duplicate]
Assuming this:
class Father():
def __init__(self,fathername):
self.papa = f"The father is {fathername.upper()}"
class Mother():
# Mother class is COMPLETELY DIFFERENT AS ...
0
votes
1
answer
638
views
Python super() chain not advancing [duplicate]
Python newbie here, would appreciate some help with multiple inheritance!
Consider the following class hierarchy:
class Base1:
def display(self):
print('Base1')
class Base2:
def ...
0
votes
1
answer
718
views
Why in Multiple Inheritance only one class init method get called [duplicate]
In Module a.py
class Foo(object):
def __init__(self):
self.foo = 20
class Bar(object):
def __init__(self):
self.bar = 10
class FooBar(Foo, Bar):
def __init__(self):
...
0
votes
1
answer
688
views
MRO in python when subclassing with multiple inheritance, using PyQt (QMainWindow) [duplicate]
I recently experienced a TypeError, that I didn't understood when I was subclassing a QMainWindow with PyQt5.
When creating two classes:
class Base (QMainWindow):
def __init__(self):
super(...
2
votes
1
answer
329
views
Understanding how super works [duplicate]
given below python program .
class FooBase(object):
def foo(self): pass
class A(FooBase):
def foo(self):
super(A, self).foo()
print 'A.foo()'
class B(FooBase):
def foo(...
0
votes
1
answer
416
views
How does Python 3 super() work in this particular multiple inheritance situation? [duplicate]
I have the following code:
class A:
def __init__(self):
print("A.__init__")
class B(A):
def __init__(self):
print("B.__init__")
super().__init__()
class C(A):
...
1
vote
1
answer
267
views
how to use super().__init__() method for 2 or more classes? [duplicate]
Here I have provided an example to illustrate my problem when a class inherits from 2 classes, then the super method only calls the constructor of the first inherited class.
import inspect
class A :
...
0
votes
0
answers
293
views
Multiple inheritance ambiguous method definitions [duplicate]
Consider Python multiple inheritance:
class A(object):
def __init__(self):
self.name = 'a'
def y(self):
return "A"
class B(A):
def __init__(self):
A.__init__(self)...
0
votes
0
answers
224
views
No dreaded diamond in python? [duplicate]
My first language(programming) C++,And now I started off with python and I could see unlike java which don't do multiple inheritance to avoid dreaded diamond problem(hopefully), the python seems to ...
1
vote
1
answer
136
views
Class Initialization [duplicate]
I just have one small question about initialization. In Python, and when we do a Multiply inherit, what's the difference between call the super function of child class and call each of them separate?
...