{"id":78130,"date":"2020-04-08T12:00:29","date_gmt":"2020-04-08T06:30:29","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=78130"},"modified":"2024-08-22T20:05:13","modified_gmt":"2024-08-22T14:35:13","slug":"multiple-inheritance-in-python","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/","title":{"rendered":"Multiple Inheritance In Python with Examples"},"content":{"rendered":"<p>As we know, <strong>Python<\/strong> supports <strong>multiple inheritance<\/strong> which gives it a <strong>plus point<\/strong> over <strong>Java<\/strong>. <strong>Java<\/strong> <strong>doesn\u2019t<\/strong> support <strong>multiple inheritance<\/strong> since it can be <strong>conflicting<\/strong> in some ways.<\/p>\n<p>In this article, we\u2019ll explore those conflicts and find ways to resolve them using Python&#8217;s Method Resolution Order (MRO). MRO ensures a predictable and consistent way to determine which method to execute when multiple parents define methods with the same name. We&#8217;ll also look at practical examples to illustrate how multiple inheritance works and how MRO resolves method conflicts.<\/p>\n<h3>What is Multiple Inheritance in Python?<\/h3>\n<p><strong>Multiple Inheritance<\/strong> is a type of <strong>inheritance<\/strong> in which <strong>one class<\/strong> can <strong>inherit properties<\/strong>(<strong>attributes<\/strong> and <strong>methods<\/strong>) of <strong>more than one<\/strong> <strong>parent classes<\/strong>.<\/p>\n<p>A practical example would be You.<\/p>\n<p>You may have <strong>inherited<\/strong> your eyes from your Mother and nose from your father. In <strong>Multiple inheritance<\/strong>, there is<strong> 1 child class<\/strong> inheriting from <strong>more<\/strong> than <strong>1 parent classes<\/strong>.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/04\/example-of-python-multiple-inheritance.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78132\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/04\/example-of-python-multiple-inheritance.jpg\" alt=\"multiple inheritance in Python\" width=\"486\" height=\"392\" \/><\/a><\/p>\n<p>Here, the child <strong>class C<\/strong> inherits from 2 parent classes, <strong>A and B.<\/strong><\/p>\n<p>Let\u2019s code it!<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class hulk:\r\n    def smash(self):\r\n        return \"I smash\"\r\n\r\nclass banner:\r\n    def speak(self):\r\n        return \"I've got the brains!\"\r\n\r\n\r\nclass smarthulk(hulk, banner):\r\n    pass\r\n\r\ns1 = smarthulk()\r\nprint(s1.smash(), \"and\", s1.speak())<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">I smash and I\u2019ve got the brain!<br \/>\n&gt;&gt;&gt;<\/div>\n<p><strong>Let\u2019s break this code down:<\/strong><\/p>\n<ul>\n<li>class smarthulk inherits from two parents classes, <strong>hulk<\/strong> and <strong>banner<\/strong>.<\/li>\n<li>So smarthulk will have all <strong>methods<\/strong> and <strong>attributes<\/strong> of both its parent classes.<\/li>\n<li>We then create an object s1 of class smarthulk and call the methods <strong>smash()<\/strong> and <strong>speak()<\/strong> on it.<\/li>\n<\/ul>\n<p>Easy right?<\/p>\n<p>But the question here is- what happens when <strong>both<\/strong> the <strong>parent classes<\/strong> have <strong>methods<\/strong> or <strong>attributes<\/strong> with the <strong>same name<\/strong>?<\/p>\n<h3>Conflicts with Multiple Inheritance<\/h3>\n<p>First, let\u2019s see what happens when the <strong>parent classes<\/strong> have <strong>attributes<\/strong> with <strong>conflicting names<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class A():  \r\n    def __init__(self):\r\n        self.name = \"Tony Stark\"\r\n   \r\nclass B():  \r\n    def __init__(self):\r\n        self.name = \"Steve Rogers\"\r\n\r\nclass C(A, B):  \r\n    def __init__(self):\r\n        A.__init__(self)\r\n        B.__init__(self)<\/pre>\n<p>Both the parent classes, <strong>A<\/strong> and <strong>B<\/strong> have the attribute <strong>\u2018name\u2019<\/strong>.<\/p>\n<p>Now if we make an <strong>object<\/strong> of <strong>class C<\/strong>, let\u2019s see which <strong>parent class\u2019s \u2018name\u2019<\/strong> attribute it <strong>inherits<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; c1 = C()\r\n&gt;&gt;&gt; c1.name<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u2018Steve Rogers\u2019<br \/>\n&gt;&gt;&gt;<\/div>\n<p>Even though <strong>class C<\/strong> <strong>inherits<\/strong> from <strong>both A<\/strong> and <strong>B<\/strong>, when we try to <strong>print<\/strong> the <strong>name attribute<\/strong> of the object of <strong>class C<\/strong>, we see <strong>\u2018Steve Rogers\u2019<\/strong> instead of<strong> \u2018Tony Stark\u2019<\/strong>.<\/p>\n<p>Now, this can be conflicting right?<\/p>\n<p>This is because when <strong>C<\/strong> <strong>calls<\/strong> the<strong> __init__<\/strong> method of <strong>class A<\/strong>, <strong>c1.name<\/strong> gets the value <strong>\u2018Tony Stark\u2019<\/strong>.<\/p>\n<p>But then <strong>C<\/strong> calls the<strong> __init__<\/strong> of <strong>class B<\/strong> and it <strong>overwrites<\/strong> the <strong>value<\/strong> of <strong>attribute c1.name<\/strong> and <strong>changes<\/strong> it to <strong>\u2018Steve Rogers\u2019<\/strong>.<\/p>\n<p>Let\u2019s now see what happens when <strong>both <\/strong>these <strong>parent<\/strong> <strong>classes<\/strong> have <strong>methods<\/strong> with the <strong>same name<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class A():  \r\n    def __init__(self):\r\n        self.name = \"Tony Stark\"\r\n\r\n    def display(self):\r\n        print(\"method of class A\")\r\n   \r\nclass B():  \r\n    def __init__(self):\r\n        self.name = \"Steve Rogers\"\r\n\r\n    def display(self):\r\n        print(\"method of class B\")\r\n  \r\nclass C(A, B):  \r\n    pass<\/pre>\n<p>Here, both the <strong>parent classes A<\/strong> and <strong>B<\/strong> have methods with the name <strong>\u2018display\u2019<\/strong>.<\/p>\n<p>Let\u2019s see which version of the <strong>display<\/strong> method gets <strong>invoked<\/strong> when we <strong>call<\/strong> it on an <strong>object<\/strong> of <strong>class C<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; c1 = C()\r\n&gt;&gt;&gt; c1.display()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">method of class A<br \/>\n&gt;&gt;&gt;<\/div>\n<p>This time, the method of <strong>class A<\/strong> gets <strong>invoked<\/strong>.<\/p>\n<p>Let\u2019s also see what happens when <strong>class C<\/strong> tries to <strong>override<\/strong> this method.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class A():  \r\n    def __init__(self):\r\n        self.name = \"Tony Stark\"\r\n\r\n    def display(self):\r\n        print(\"method of class A\")\r\n   \r\nclass B():  \r\n    def __init__(self):\r\n        self.name = \"Steve Rogers\"\r\n\r\n    def display(self):\r\n        print(\"method of class B\")\r\n  \r\n\r\nclass C(A, B):  \r\n    def display(self):\r\n        print(\"method of class C\")<\/pre>\n<p>Let\u2019s call the display method again.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; c1 = C()\r\n&gt;&gt;&gt; c1.display()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">method of class C<\/div>\n<p>Now, the interpreter <strong>calls<\/strong> <strong>display<\/strong> of <strong>C<\/strong>.<\/p>\n<p>Losing your mind?<\/p>\n<p>Well, this last discussion on <strong>Method Resolution Order(MRO)<\/strong> will make it perfectly clear to you.<\/p>\n<h3>Method Resolution Order<\/h3>\n<p>We have <strong>modified<\/strong> our previous <strong>code<\/strong> to get a <strong>deeper understanding<\/strong> of what\u2019s happening with each<strong> __init__ call<\/strong>. Also, we have used <strong>super<\/strong> to invoke the <strong>__init__<\/strong> method of the <strong>superclass<\/strong> of <strong>C<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class A():  \r\n    def __init__(self):\r\n        print(\"Starting __init__ of A\")\r\n        self.name = \"Tony Stark\"\r\n        print(\"ending __init__ of A\")\r\n\r\n    def display(self):\r\n        print(\"method of class A\")\r\n   \r\nclass B():  \r\n    def __init__(self):\r\n        print(\"Starting __init__ of B\")\r\n        self.name = \"Steve Rogers\"\r\n        print(\"ending __init__ of B\")\r\n        \r\n    def display(self):\r\n        print(\"method of class B\")\r\n  \r\n\r\nclass C(A, B):\r\n    def __init__(self):\r\n        print(\"Starting __init__ of C\")\r\n        super().__init__()\r\n        print(\"ending __init__ of C\")\r\n        \r\n    def display(self):\r\n        print(\"method of class C\")<\/pre>\n<p>Test is in the Python shell:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; c1 = C()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Starting __init__ of C<br \/>\nStarting __init__ of A<br \/>\nending __init__ of A<br \/>\nending __init__ of C<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; c1.name<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\u2018Tony Stark\u2019<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; c1.display()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">method of class C<br \/>\n&gt;&gt;&gt;<\/div>\n<p>So when we <strong>create<\/strong> a new instance of <strong>class C<\/strong>, it <strong>calls<\/strong> its <strong>constructor<\/strong>, i.e, the <strong>__init__<\/strong> method of <strong>C<\/strong>.<\/p>\n<p>The <strong>super<\/strong> in the <strong>__init__<\/strong> of class <strong>C<\/strong> then <strong>calls<\/strong> the <strong>__init__<\/strong> method of the <strong>superclass<\/strong> of <strong>C<\/strong>. Note that only the<strong> __init__ of<\/strong> <strong>A<\/strong> gets <strong>called<\/strong> and that of <strong>B<\/strong> remains <strong>untouched<\/strong>.<\/p>\n<p>Why? To understand this let\u2019s look at the <strong>MRO hierarchy<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; C.mro()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[&lt;class &#8216;__main__.C&#8217;&gt;, &lt;class &#8216;__main__.A&#8217;&gt;, &lt;class &#8216;__main__.B&#8217;&gt;, &lt;class &#8216;object&#8217;&gt;]<\/div>\n<p>This shows the <strong>order<\/strong> in which <strong>MRO<\/strong> searches for a method in an <strong>inheritance hierarchy<\/strong>.<\/p>\n<p>The <strong>MRO chain<\/strong> for <strong>C<\/strong> is: <strong>C -&gt; A -&gt; B<\/strong><\/p>\n<p>The <strong>super() <\/strong>method simply <strong>calls<\/strong> the <strong>method<\/strong> of the <strong>next class<\/strong> in the <strong>hierarchy<\/strong>. Since we had a <strong>super() <\/strong>method in the <strong>__init__ of C<\/strong>, the<strong> __init__<\/strong> of the <strong>next class<\/strong>, i.e, <strong>A<\/strong> gets <strong>invoked<\/strong>.<\/p>\n<p>If we had a<strong> super()<\/strong> in the <strong>__init__ of A<\/strong>, it would have <strong>called<\/strong> the <strong>__init__ of B<\/strong>. (Since B comes next in the MRO chain).<\/p>\n<p>(Note: <strong>object<\/strong> is the <strong>parent class<\/strong> from which <strong>every class inherits<\/strong> by <strong>default<\/strong> in <strong>Python<\/strong>).<\/p>\n<p>Let\u2019s reason out how <strong>MRO<\/strong> takes place in Python:<\/p>\n<ul>\n<li>In the case of <strong>multiple inheritance<\/strong>, the <strong>attribute\/method<\/strong> is first <strong>looked<\/strong> <strong>up<\/strong> in the <strong>current class<\/strong>.<\/li>\n<li>If the <strong>interpreter<\/strong> does not find the said <strong>attribute\/method<\/strong>, then it <strong>searches<\/strong> for it in the <strong>next class<\/strong> in the <strong>MRO hierarchy<\/strong>.<\/li>\n<li>If it <strong>fails<\/strong> to find it in any of the <strong>classes<\/strong> in the <strong>hierarchy<\/strong>, it <strong>spits<\/strong> out an <strong>error message<\/strong> saying there is <strong>no definition<\/strong> of the <strong>attribute\/method<\/strong> you are looking for.<\/li>\n<li>In case of multiple parent classes, MRO searchers in a <strong>depth-first<\/strong> order followed by a <strong>left-right<\/strong> path.<\/li>\n<\/ul>\n<p>Now, getting back to our <strong>example code<\/strong>.<\/p>\n<p>When we <strong>call<\/strong> the <strong>\u2018name\u2019<\/strong> <strong>attribute<\/strong> on <strong>c1<\/strong>, the <strong>interpreter<\/strong> first <strong>searches<\/strong> for it in <strong>class C<\/strong>. When it <strong>doesn\u2019t<\/strong> find the <strong>attribute<\/strong>, it searches for it in the <strong>next class<\/strong> in the<strong> MRO chain<\/strong>, i.e. <strong>A<\/strong>. And finally <strong>displays<\/strong> the <strong>attribute\u2019s value<\/strong> once it <strong>finds<\/strong> it.<\/p>\n<p>The same thing happens while <strong>calling<\/strong> the <strong>display method<\/strong> on <strong>c1<\/strong>.<\/p>\n<p>The <strong>interpreter<\/strong> finds a <strong>definition<\/strong> of <strong>display method<\/strong> in <strong>class C<\/strong> and hence <strong>invokes class C\u2019s<\/strong> version of <strong>display<\/strong>. In case it <strong>doesn\u2019t find<\/strong> the <strong>method\u2019s definition<\/strong> in <strong>C<\/strong>, it <strong>moves on<\/strong> and <strong>searches deeper<\/strong> in the <strong>hierarchy<\/strong>. This is how <strong>MRO<\/strong> <strong>works<\/strong>.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this python article, we learned about the <strong>implementation<\/strong> of <strong>multiple inheritance<\/strong> in <strong>Python<\/strong>.<\/p>\n<p>We also saw what <strong>conflicts<\/strong> you might come across while <strong>working<\/strong> with <strong>python multiple inheritance<\/strong>.<\/p>\n<p>Then we learned how the <strong>interpreter<\/strong> uses the <strong>Method Resolution Order<\/strong> to <strong>determine<\/strong> which version of a <strong>method\/attribute<\/strong> gets <strong>called<\/strong> in case of <strong>multiple inheritance<\/strong>.<\/p>\n<p>Hope you got a <strong>clear understanding<\/strong> of what happens under the hood and how you can take <strong>advantage<\/strong> of <strong>multiple inheritance<\/strong> in your <strong>program<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we know, Python supports multiple inheritance which gives it a plus point over Java. Java doesn\u2019t support multiple inheritance since it can be conflicting in some ways. In this article, we\u2019ll explore those&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":78134,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[2368,2369,1454,2370,2371,2372],"class_list":["post-78130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-method-resolution-order-in-python","tag-mro","tag-multiple-inheritance-in-python","tag-python-mro","tag-python-multiple-inheritance","tag-python-multiple-inheritance-example"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Multiple Inheritance In Python with Examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn multiple inheritance in python with examples. Understand the conflicts in multiple inheritance and how Method resolution order works.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Multiple Inheritance In Python with Examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn multiple inheritance in python with examples. Understand the conflicts in multiple inheritance and how Method resolution order works.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-08T06:30:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-22T14:35:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/python-multiple-inheritance.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Multiple Inheritance In Python with Examples - TechVidvan","description":"Learn multiple inheritance in python with examples. Understand the conflicts in multiple inheritance and how Method resolution order works.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Multiple Inheritance In Python with Examples - TechVidvan","og_description":"Learn multiple inheritance in python with examples. Understand the conflicts in multiple inheritance and how Method resolution order works.","og_url":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-04-08T06:30:29+00:00","article_modified_time":"2024-08-22T14:35:13+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/python-multiple-inheritance.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Multiple Inheritance In Python with Examples","datePublished":"2020-04-08T06:30:29+00:00","dateModified":"2024-08-22T14:35:13+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/"},"wordCount":1069,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/python-multiple-inheritance.jpg","keywords":["Method resolution Order in Python","MRO","Multiple Inheritance in Python","python MRO","Python Multiple Inheritance","python multiple inheritance example"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/","url":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/","name":"Multiple Inheritance In Python with Examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/python-multiple-inheritance.jpg","datePublished":"2020-04-08T06:30:29+00:00","dateModified":"2024-08-22T14:35:13+00:00","description":"Learn multiple inheritance in python with examples. Understand the conflicts in multiple inheritance and how Method resolution order works.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/python-multiple-inheritance.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/python-multiple-inheritance.jpg","width":802,"height":420,"caption":"Multiple Inheritance in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/multiple-inheritance-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Multiple Inheritance In Python with Examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/78130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=78130"}],"version-history":[{"count":1,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/78130\/revisions"}],"predecessor-version":[{"id":447689,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/78130\/revisions\/447689"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/78134"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=78130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=78130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=78130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}