- Does Python Support Multiple Inheritance? if not then any other alternatives for multiple inheritance?
- Can we do method overloading in python?
-
Just one thing. Do you really understand what multiple inheritance is? Did you use in, say, C++ or is Python your first try on OOP? If so, consider that languages like Java and C# did intentionally do without multiple inheritance because it has a conceptual complexity that is easily underestimated. Before diving into this I'd recommend to read more about why it is so difficult to really understand and use and how to avoid it... just my two cents :) Good study and coding to you!pid– pid2019-10-08 19:49:51 +00:00Commented Oct 8, 2019 at 19:49
-
At least study and understand the "Diamond problem"!pid– pid2019-10-08 19:52:00 +00:00Commented Oct 8, 2019 at 19:52
-
@pid yes i know what the multiple inheritance is. I was learnt oop concepts in java and handle multiple inheritance using interface but in python there is a lot of oop concepts which are not directly availabe for example __ for declaring the method as abstract.'abc' module for abstraction and so on but what i want to know here is python support multiple inheritance directly or not? because python does not support interfaces.Shaheer– Shaheer2019-10-09 14:51:56 +00:00Commented Oct 9, 2019 at 14:51
Add a comment
|
1 Answer
Yes python supports multiple inheritance.
Here is a example:
class Base1:
pass
class Base2:
pass
class MultiDerived(Base1, Base2):
pass
And another example:
class Base:
pass
class Derived1(Base):
pass
class Derived2(Derived1):
pass
Yes, python does support function overloading.
3 Comments
Shaheer
For first exmple: Does this approach works when both base1 and base2 have concrete methods?
Shaheer
thanks for your response. yes i try and implement your first example and it works fine.now i totally understand how to handle multiple inheritance in python.
Joystick
Yes, Sheri i think so, if there are concrete methods then the function in that object gets called. If there are abstract methods than the child overrides the method of parent class.

