{"id":17563,"date":"2017-06-28T16:15:12","date_gmt":"2017-06-28T13:15:12","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=17563"},"modified":"2018-01-09T09:37:59","modified_gmt":"2018-01-09T07:37:59","slug":"python-class-inheritance-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/","title":{"rendered":"Python Class Inheritance Example"},"content":{"rendered":"<p>Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk about basic principles of programming. We know that there is an imperative method (when we use for and while loops), functional (when we operate with functions) or Object Oriented Programming (where we write code using classes).<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;R7QVpFMZmjosABLC&#8217;]<\/p>\n<h2>1. Intro to Classes<\/h2>\n<p>We know many data structures that Python has: tuples (which are basically immutable arrays of objects), lists (same as tuples, but they are actually mutable) and dictionaries (which can be represented as hash tables). They are all good, but sometimes you need better tools to implement things you want.<br \/>\nFor example, we have a company that has different workers who hold various job positions. We can surely put all data in an array (which would take a long time), dictionary (which would be a better option, but still time-consuming) or we can just create a Class <code>worker<\/code> with parameters explaining their job positions, work experience, salary, etc. That way, if we want to extract some information or add something new, we would operate with specific Class.<br \/>\nSo basically, Classes are structures or, in other words, skeletons of our data which we will eventually fill in. Then another question comes up, \u201cHow can we fill the structure?\u201d<\/p>\n<h2>2. Intro to Instances<\/h2>\n<p>Well, we have an idea what Class is. It\u2019s a structure, showing us with what and how to fill it. If we want to fill it (which we surely do!), we need to create instances. It\u2019s a copy of class that is filled with data.<br \/>\nLet\u2019s look at the example below with workers in a company, shall we?<br \/>\nWe are creating a class called <code>worker<\/code> with parameters <code>name<\/code>, <code>position<\/code>, and <code>experience<\/code>:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>main.py<\/em><\/span><\/p>\n<pre class=\"brush:python; highlight:[1,2,3,4,5,6,7,8,9,10,11,12,13]\">class worker(object): \r\n\r\n   def __init__(self,name,position, experience):\r\n      self.name = name\r\n      self.position = position\r\n      self.experience = experience\r\n   def getName(self):\r\n      return self.name\r\n   def getPosition(self):\r\n      return self.experience\r\n   def getExperience(self):\r\n      return self.experience\r\n   def __str__(self):\r\n     return \"%s is %s and has been working here for the past %d years\" %(self.name, self.position, self.experience)\r\n<\/pre>\n<p>Line 1: We are creating the class. The word <code>class<\/code> means that we tell Python to create a class and the word <code>worker<\/code> is the name of it! The word <code>object<\/code> is just a special variable that needs to be included in order to create a new class.<\/p>\n<p>Lines 2-5: We are creating a function by writing <code>def<\/code>. Then we are using magic method (as known as <b>Dunder<\/b>) called <code>__init__<\/code>. The key idea for using it is because we are creating an instance of class firstly.<br \/>\nThe word <code>self<\/code> is the instance of the class <code>worker<\/code>. This is done so we can insert different data depending upon various circumstances.<\/p>\n<p>Lines 6-11: We are creating functions that return instances of the class. For example, the <code>getPosition<\/code> method takes an instance of a <code>worker<\/code> as a parameter and looks up the worker\u2019s job position. Note: we use <code>self<\/code> to figure out the content (which can be done automatically by Python).<br \/>\nLet\u2019s create John who has worked with the company for 15 years and he is a manager:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Python shell<\/em><\/span><\/p>\n<pre class=\"brush:bash\">&gt;&gt;&gt;  first = worker(\"John\", \"manager\", 15)<\/pre>\n<p>Then we will try to retrieve information about him:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Python shell<\/em><\/span><\/p>\n<pre class=\"brush:bash\">&gt;&gt;&gt;  first = worker(\"John\", \"manager\", 15)\r\n&gt;&gt;&gt;  first.getName()\r\n'John'\r\n&gt;&gt;&gt;  first.getPosition()\r\n'manager'\r\n&gt;&gt;&gt;  first.getExperience()\r\n15\r\n&gt;&gt;&gt; print(first)\r\nJohn is manager and has been working here for the past 15 years<\/pre>\n<p>It works! So what we do here is every time we call methods <code>getName<\/code>, <code>getPosition<\/code> or <code>getExperience<\/code> we receive information about itself.<\/p>\n<p>Lines 12-13: Another magic method is <code>__str__<\/code> which defines the behavior of what will happen if we write <code>print(Class name) <\/code>.<br \/>\nLet\u2019s try to add more workers:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Python shell<\/em><\/span><\/p>\n<pre class=\"brush:bash\">&gt;&gt;&gt;  second = worker(\"Monica\", \"programmer\", 12)\r\n&gt;&gt;&gt;  print(second)\r\nMonica is programmer and has been working here for the past 12 years\r\n&gt;&gt;&gt;  third = worker(\"Jimmy\", \"programmer\", 2)\r\n&gt;&gt;&gt;  print(third)\r\nJimmy is programmer and has been working here for the past 12 years\r\n&gt;&gt;&gt;  fourth = worker(\"Lisa\", \"manager\", 4)\r\n&gt;&gt;&gt;  print(fourth)\r\nLisa is manager and has been working here for the past 12 years<\/pre>\n<p>You are probably asking right now, \u201cOkay, we create classes. It\u2019s fun but wait\u2026 What if we have not 4 but 400 people in the company? We can\u2019t create instances all the time and we can\u2019t sort people like that. It\u2019s too complex!\u201d I am glad that you asked! There is another thing called <b>subclasses<\/b>.<\/p>\n<h2>3. Intro to subclasses<\/h2>\n<p>Well, maybe we have John and Lisa as managers, Monica and Jimmy as programmers. Let\u2019s create subclasses <code>programming<\/code> and <code>management<\/code>. Firstly, let\u2019s see what we can do with the class <code>management<\/code>:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>main.py<\/em><\/span><\/p>\n<pre class=\"brush:python; highlight:[3]\">class management(worker):\r\n   def __init__(self, name, management_skills, experience):\r\n      worker.__init__(self, name, \"management\", experience)\r\n      self.management_skills = management_skills\r\n   def management_skills(self):\r\n      return self.management_skills\r\n<\/pre>\n<p>What we want to do here is to specify that all <code>management<\/code> have position <code>manager<\/code>. Since we want name, position, and experience to be initialized, we write the line 3.<br \/>\nLet\u2019s see what happen in Python shell when we find differences between <code>worker<\/code> and <code>management<\/code>:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Python shell<\/em><\/span><\/p>\n<pre class=\"brush:bash\">&gt;&gt;&gt;  example_worker = worker(\"Alex\", \"programmer\", 1)\r\n&gt;&gt;&gt;  example_management = management(\"Aleks\", \"manager\", 1)<\/pre>\n<p>What we want to check right now is whether one instance is certain class\u2019s instance. We can do it by calling <code>isinstance()<\/code>:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Python shell<\/em><\/span><\/p>\n<pre class=\"brush:bash\">&gt;&gt;&gt;  isinstance(example_worker, worker)\r\nTrue\r\n&gt;&gt;&gt;  isinstance(example_worker, management)\r\nFalse\r\n&gt;&gt;&gt;  isinstance(example_management, worker)\r\nTrue\r\n&gt;&gt;&gt;  isinstance(example_management, management)\r\nTrue<\/pre>\n<p>One thing may seem confusing to you right now, \u201cWhy is <code>example_management<\/code> and <code>worker<\/code> returns true?\u201d. That\u2019s a very good question! Since management is worker\u2019s subclass, it inherits attributes of it. In other words, worker is a base for management, so every time we check for worker as a second parameter, we get <code>True<\/code>. But we can only get <code>True<\/code> while calling for management if we are calling the very same subclass (which is the last line of the code above).<\/p>\n<h2>4. Summary<\/h2>\n<p>In the example above we saw multiple things:<\/p>\n<ul>\n<li><em>Inheritance:<\/em> It&#8217;s one of the paradigms of OOP. It helps you to write code more efficiently but can be tricky at the beginning.<\/li>\n<li><em>Instances:<\/em> It&#8217;s a copy of class with filled data. Basically, when you want to build a class, you explain what data will be put there, but an instance is a complete class with filled data in it.<\/li>\n<li><em>Magic methods:<\/em> Those are special methods for operator overloading. A good example of such is <code>__add__<\/code> that means <code>+<\/code>. There are plenty of those, like <code>__sub__<\/code>, <code>__mul__<\/code>, <code>__truediv__<\/code>, <code>__mod__<\/code> and many others.<\/li>\n<li><em>Subclasses:<\/em> They are used when you have data with common attributes. For example, you have a farm with 1000 animals. Most of them have 4 legs, and you want to collect data from those who have fewer than 4 legs (like ducks or something like that). That&#8217;s why you would need to use subclasses &#8211; to classify multiple arrays of objects in specific arrays with special attributes<\/li>\n<\/ul>\n<h2>5. Instead of conclusion<\/h2>\n<p>I hope inheritance seems more logical for you now (if you were struggling with it). In fact, the best way to learn about classes and inheritance is to actually write code. It plays vital role in DRY principle (as known as <b>D<\/b>on\u2019t <b>R<\/b>epeat <b>Y<\/b>ourself).<br \/>\nSurely, there is a lot more you need to know in order to advance: encapsulation, polymorphism, static classes, abstract classes, etc.<\/p>\n<p>So here is some homework for you:<br \/>\n<i>Write a program where class of geometric figure (<b>figure<\/b>) consists of color (<b>color<\/b>) with the default set as white and method of changing the figure. Its subclasses are oval (<b>oval<\/b>) and parallelepiped (<b>parallelepiped<\/b>) which have methods <code><b>__init__<\/b><\/code> to set size of objects <\/i><\/p>\n<p>Example of how it can be done can be seen below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>homework.py<\/em><\/span><\/p>\n<pre class=\"brush:python\">class figure():\r\n   color = \"white\"\r\n   def changecolor(self, newcolor):\r\n      self.color = newcolor\r\n\r\nclass oval(figure):\r\n   def __init__(self, radius):\r\n      self.radius = radius\r\n\r\nclass parallelepiped(figure):\r\n   def __init__(self, width, height):\r\n      self.width = width\r\n      self.height = height\r\n\r\nf = figure()\r\no = oval(10)\r\np = parallelepiped(20,5)\r\np.changecolor(\"green\")\r\n\r\nprint(o.color, o.radius)\r\nprint(p.color, p.width, p.height)\r\n<\/pre>\n<h2>6. Download the source code<\/h2>\n<p>This was an example of inheritance.<\/p>\n<div class=\"download\"><strong>Downoload<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/python-class-inheritance.zip\"><strong>python-class-inheritance.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk about basic principles of programming. We know that there is an imperative method (when we use for and while loops), functional (when we operate with functions) or Object Oriented &hellip;<\/p>\n","protected":false},"author":657,"featured_media":1651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[290,473],"class_list":["post-17563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python","tag-python-inheritance"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Class Inheritance Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Class Inheritance Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-28T13:15:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T07:37:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Aleksandr Krasnov\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aleksandr Krasnov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\"},\"author\":{\"name\":\"Aleksandr Krasnov\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e07867bd46d3c03c70d9566277772373\"},\"headline\":\"Python Class Inheritance Example\",\"datePublished\":\"2017-06-28T13:15:12+00:00\",\"dateModified\":\"2018-01-09T07:37:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\"},\"wordCount\":1088,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"keywords\":[\"python\",\"python inheritance\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\",\"name\":\"Python Class Inheritance Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"datePublished\":\"2017-06-28T13:15:12+00:00\",\"dateModified\":\"2018-01-09T07:37:59+00:00\",\"description\":\"Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Class Inheritance Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e07867bd46d3c03c70d9566277772373\",\"name\":\"Aleksandr Krasnov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/773b350dfd4fa0aa4470113fe22f39c38db44fc456aef63c609bf8f05e424dc6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/773b350dfd4fa0aa4470113fe22f39c38db44fc456aef63c609bf8f05e424dc6?s=96&d=mm&r=g\",\"caption\":\"Aleksandr Krasnov\"},\"description\":\"Aleksandr is passionate about teaching programming. His main interests are Neural Networks, Python and Web development. Hobbies are game development and translating. For the past year, he has been involved in different international projects as SEO and IT architect.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/aleksandr-krasnov\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Class Inheritance Example - Web Code Geeks - 2026","description":"Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk","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:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/","og_locale":"en_US","og_type":"article","og_title":"Python Class Inheritance Example - Web Code Geeks - 2026","og_description":"Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk","og_url":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-06-28T13:15:12+00:00","article_modified_time":"2018-01-09T07:37:59+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","type":"image\/jpeg"}],"author":"Aleksandr Krasnov","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Aleksandr Krasnov","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/"},"author":{"name":"Aleksandr Krasnov","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e07867bd46d3c03c70d9566277772373"},"headline":"Python Class Inheritance Example","datePublished":"2017-06-28T13:15:12+00:00","dateModified":"2018-01-09T07:37:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/"},"wordCount":1088,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","keywords":["python","python inheritance"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/","url":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/","name":"Python Class Inheritance Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","datePublished":"2017-06-28T13:15:12+00:00","dateModified":"2018-01-09T07:37:59+00:00","description":"Today we will be talking about OOP method of programming. The particular area of our interest would be Inheritance. Before we go any further, let\u2019s talk","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/python\/python-class-inheritance-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/www.webcodegeeks.com\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Class Inheritance Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e07867bd46d3c03c70d9566277772373","name":"Aleksandr Krasnov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/773b350dfd4fa0aa4470113fe22f39c38db44fc456aef63c609bf8f05e424dc6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/773b350dfd4fa0aa4470113fe22f39c38db44fc456aef63c609bf8f05e424dc6?s=96&d=mm&r=g","caption":"Aleksandr Krasnov"},"description":"Aleksandr is passionate about teaching programming. His main interests are Neural Networks, Python and Web development. Hobbies are game development and translating. For the past year, he has been involved in different international projects as SEO and IT architect.","url":"https:\/\/www.webcodegeeks.com\/author\/aleksandr-krasnov\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/657"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=17563"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17563\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/1651"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=17563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}