{"id":538,"date":"2020-10-14T05:56:49","date_gmt":"2020-10-14T05:56:49","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=538"},"modified":"2025-03-31T10:11:33","modified_gmt":"2025-03-31T10:11:33","slug":"python-inheritance","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/python-oop\/python-inheritance\/","title":{"rendered":"Python Inheritance"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn about Python inheritance and how to use the inheritance to reuse code from an existing class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-python-inheritance'>Introduction to the Python inheritance <a href=\"#introduction-to-the-python-inheritance\" class=\"anchor\" id=\"introduction-to-the-python-inheritance\" title=\"Anchor for Introduction to the Python inheritance\">#<\/a><\/h2>\n\n\n\n<p>Inheritance allows a <a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-class\/\">class<\/a> to reuse the logic of an existing class. Suppose you have the following <code>Person<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Person<\/span>:<\/span>\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">__init__<\/span><span class=\"hljs-params\">(self, name)<\/span>:<\/span>\n        self.name = name\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">greet<\/span><span class=\"hljs-params\">(self)<\/span>:<\/span>\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">f\"Hi, it's <span class=\"hljs-subst\">{self.name}<\/span>\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>Person<\/code> class has the <code>name<\/code> attribute and the <code>greet()<\/code> method.<\/p>\n\n\n\n<p>Now, you want to define the <code>Employee<\/code> that is similar to the <code>Person<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Employee<\/span>:<\/span>\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">__init__<\/span><span class=\"hljs-params\">(self, name, job_title)<\/span>:<\/span>\n        self.name = name\n        self.job_title = job_title\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">greet<\/span><span class=\"hljs-params\">(self)<\/span>:<\/span>\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">f\"Hi, it's <span class=\"hljs-subst\">{self.name}<\/span>\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>Employee<\/code> class has two attributes <code>name<\/code> and <code>job_title<\/code>. It also has the <code>greet()<\/code> method that is exactly the same as the <code>greet()<\/code> method of the <code>Person<\/code> class.<\/p>\n\n\n\n<p>To reuse the <code>greet()<\/code> method from the <code>Person<\/code> class in the <code>Employee<\/code> class, you can create a relationship between the <code>Person<\/code> and <code>Employee<\/code> classes. To do it, you use inheritance so that the <code>Employee<\/code> class inherits from the <code>Person<\/code> class. <\/p>\n\n\n\n<p>The following redefines the <code>Employee<\/code> class that inherits from the <code>Person<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Employee<\/span><span class=\"hljs-params\">(Person)<\/span>:<\/span>\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">__init__<\/span><span class=\"hljs-params\">(self, name, job_title)<\/span>:<\/span>\n        self.name = name\n        self.job_title = job_title<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>By doing this, the <code>Employee<\/code> class behaves the same as the <code>Person<\/code> class without redefining the greet() method. <\/p>\n\n\n\n<p>This is a <strong>single inheritance<\/strong> because the <code>Employee<\/code> inherits from a single class (<code>Person<\/code>). Note that Python also supports multiple inheritances where a class inherits from multiple classes.<\/p>\n\n\n\n<p>Since the <code>Employee<\/code> inherits attributes and methods of the <code>Person<\/code> class, you can use the instance of the Employee class as if it were an instance of the <code>Person<\/code> class. <\/p>\n\n\n\n<p>For example, the following creates a new instance of the <code>Employee<\/code> class and call the <code>greet()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">employee = Employee(<span class=\"hljs-string\">'John'<\/span>, <span class=\"hljs-string\">'Python Developer'<\/span>)\nprint(employee.greet())<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">Hi, it<span class=\"hljs-string\">'s John<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='inheritance-terminology'>Inheritance terminology <a href=\"#inheritance-terminology\" class=\"anchor\" id=\"inheritance-terminology\" title=\"Anchor for Inheritance terminology\">#<\/a><\/h3>\n\n\n\n<p>The <code>Person<\/code> class is the <strong>parent class<\/strong>, the <strong>base class<\/strong>, or the <strong>super class<\/strong> of the <code>Employee<\/code> class. And the <code>Employee<\/code> class is a <strong>child <\/strong>class, a <strong>derived class<\/strong>, or a <strong>subclass <\/strong>of the <code>Person<\/code> class.<\/p>\n\n\n\n<p>The <code>Employee<\/code> class <strong>derives from<\/strong>, <strong>extends<\/strong>, or <strong>subclasses <\/strong>the <code>Person<\/code> class.<\/p>\n\n\n\n<p>The relationship between the <code>Employee<\/code> class and <code>Person<\/code> class is <strong>IS-A<\/strong> relationship. In other words, an employee <strong>is a<\/strong> person.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='type-vs-isinstance'>type vs. isinstance <a href=\"#type-vs-isinstance\" class=\"anchor\" id=\"type-vs-isinstance\" title=\"Anchor for type vs. isinstance\">#<\/a><\/h2>\n\n\n\n<p>The following shows the type of instances of the <code>Person<\/code> and <code>Employee<\/code> classes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">person = Person(<span class=\"hljs-string\">'Jane'<\/span>)\nprint(type(person))\n\nemployee = Employee(<span class=\"hljs-string\">'John'<\/span>, <span class=\"hljs-string\">'Python Developer'<\/span>)\nprint(type(employee))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">&lt;<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> '<span class=\"hljs-title\">__main__<\/span>.<span class=\"hljs-title\">Person<\/span>'&gt;\n&lt;<span class=\"hljs-title\">class<\/span> '<span class=\"hljs-title\">__main__<\/span>.<span class=\"hljs-title\">Employee<\/span>'&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To check if an object is an instance of a class, you use the <code>isinstance()<\/code> method. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">person = Person(<span class=\"hljs-string\">'Jane'<\/span>)\nprint(isinstance(person, Person))  <span class=\"hljs-comment\"># True<\/span>\n\nemployee = Employee(<span class=\"hljs-string\">'John'<\/span>, <span class=\"hljs-string\">'Python Developer'<\/span>)\nprint(isinstance(employee, Person))  <span class=\"hljs-comment\"># True<\/span>\nprint(isinstance(employee, Employee))  <span class=\"hljs-comment\"># True<\/span>\nprint(isinstance(person, Employee))  <span class=\"hljs-comment\"># False<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-literal\">True<\/span>\n<span class=\"hljs-literal\">True<\/span>\n<span class=\"hljs-literal\">True<\/span>\n<span class=\"hljs-literal\">False<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The output indicates:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>person<\/code> is an instance of the <code>Person<\/code> class.<\/li>\n\n\n\n<li>The <code>employee<\/code> is an instance of the <code>Employee<\/code> class. It&#8217;s also an instance of the <code>Person<\/code> class.<\/li>\n\n\n\n<li>The <code>person<\/code> is not an instance of the <code>Employee<\/code> class.<\/li>\n<\/ul>\n\n\n\n<p>In practice, you&#8217;ll often use the <code>isinstance()<\/code> function to check whether an object has certain methods. Then, you&#8217;ll call the methods of that object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='issubclass'>issubclass <a href=\"#issubclass\" class=\"anchor\" id=\"issubclass\" title=\"Anchor for issubclass\">#<\/a><\/h3>\n\n\n\n<p>To check if a class is a subclass of another class, you use the <code>issubclass()<\/code> function. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(issubclass(Employee, Person)) <span class=\"hljs-comment\"># True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following defines the <code>SalesEmployee<\/code> class that inherits from the <code>Employee<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">SalesEmployee<\/span><span class=\"hljs-params\">(Employee)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">pass<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>SalesEmployee<\/code> is the subclass of the <code>Employee<\/code> class. It&#8217;s also a subclass of the <code>Person<\/code> class as shown in the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(issubclass(SalesEmployee, Employee)) <span class=\"hljs-comment\"># True<\/span>\nprint(issubclass(SalesEmployee, Person)) <span class=\"hljs-comment\"># True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Note that when you define a class that doesn&#8217;t inherit from any class, it&#8217;ll implicitly inherit from the built-in <code>object<\/code> class.<\/p>\n\n\n\n<p>For example, the <code>Person<\/code> class inherits from the <code>object<\/code> class implicitly. Therefore, it is a subclass of the <code>object<\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(issubclass(Person, object)) <span class=\"hljs-comment\"># True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In other words, all classes are subclasses of the <code>object<\/code> class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Inheritance allows a class to reuse existing attributes and methods of another class.<\/li>\n\n\n\n<li>The class that inherits from another class is called a child class, a subclass, or a derived class. <\/li>\n\n\n\n<li>The class from which other classes inherit is called a parent class, a super class, or a base class.<\/li>\n\n\n\n<li>Use <code>isinstance()<\/code> to check if an object is an instance of a class.<\/li>\n\n\n\n<li>Use <code>issubclass()<\/code> to check if a class is a subclass of another class.<\/li>\n<\/ul>\n\n\n\n<iframe loading=\"lazy\"\n  name=\"quiz\"\n  src=\"\/quiz\/?quiz=inheritance\"\n  height=\"700\"\n  width=\"600\"\n  class=\"iframe\"\n><\/iframe>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"538\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-oop\/python-inheritance\/\"\n\t\t\t\tdata-post-title=\"Python Inheritance\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"538\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-oop\/python-inheritance\/\"\n\t\t\t\tdata-post-title=\"Python Inheritance\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn about Python inheritance and how to use the inheritance to reuse code from an existing class.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":417,"menu_order":21,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-538","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=538"}],"version-history":[{"count":3,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/538\/revisions"}],"predecessor-version":[{"id":7313,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/538\/revisions\/7313"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/417"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}