0
  1. Does Python Support Multiple Inheritance? if not then any other alternatives for multiple inheritance?
  2. Can we do method overloading in python?
3
  • 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! Commented Oct 8, 2019 at 19:49
  • At least study and understand the "Diamond problem"! Commented 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. Commented Oct 9, 2019 at 14:51

1 Answer 1

2

Yes python supports multiple inheritance.

Here is a example:

class Base1:
    pass
class Base2:
    pass
class MultiDerived(Base1, Base2):
    pass

pic1

And another example:

class Base:
    pass
class Derived1(Base):
    pass
class Derived2(Derived1):
    pass

pic2

Yes, python does support function overloading.

Sign up to request clarification or add additional context in comments.

3 Comments

For first exmple: Does this approach works when both base1 and base2 have concrete methods?
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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.