{"id":1340,"date":"2020-04-20T08:30:37","date_gmt":"2020-04-20T15:30:37","guid":{"rendered":"https:\/\/renanmf.com\/?p=1340"},"modified":"2021-09-06T14:43:05","modified_gmt":"2021-09-06T17:43:05","slug":"classes-objects-python","status":"publish","type":"post","link":"https:\/\/renanmf.com\/classes-objects-python\/","title":{"rendered":"Classes and Objects in Python"},"content":{"rendered":"<p>This is the 1st article in a series on Object-Oriented Programming:<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/renanmf.com\/classes-objects-python\/\">Classes and Objects in Python<\/a><\/strong><\/li>\n<li><a href=\"https:\/\/renanmf.com\/object-oriented-programming-encapsulation-in-python\/\">Object-Oriented Programming: Encapsulation in Python<\/a><\/li>\n<li><a href=\"https:\/\/renanmf.com\/inheritance-python\/\">Inheritance in Python<\/a><\/li>\n<li><a href=\"https:\/\/renanmf.com\/object-oriented-programming-polymorphism-in-python\/\">Object-Oriented Programming: Polymorphism in Python<\/a><\/li>\n<\/ul>\n<hr \/>\n<p>Classes and Objects are the fundamental concepts of Object-Oriented Programming.<\/p>\n<p>In Python, <strong>everything is an object<\/strong>!<\/p>\n<p>A variable (object) is just an instance of its type (class).<\/p>\n<p>That\\&#8217;s why when you check the type of a variable you can see the <code>class<\/code> keyword right next to its type (class).<\/p>\n<p>This code snippet shows that <code>my_city<\/code> is an object and it is an instance of the class <code>str<\/code>.<\/p>\n<pre><code class=\"language-python\">my_city = &quot;New York&quot;\nprint(type(my_city))<\/code><\/pre>\n<pre><code>&lt;class &#039;str&#039;&gt;<\/code><\/pre>\n<h2>Differentiate Class x Object<\/h2>\n<p>The class gives you a standard way to create objects, a class is like a base project.<\/p>\n<p>Say you are an engineer working for Boeing.<\/p>\n<p>Your new mission is to build the new product for the company, a new model called 747-Space, this aircraft flies higher altitudes than other commercial models.<\/p>\n<p>Boeing needs to build dozens of those to sell to airlines all over the world, the aircrafts have to be all the same.<\/p>\n<p>To guarantee that the aircrafts (objects) follow the same standards, you need to have a project (class) that can be replicable.<\/p>\n<p>The class is a project, a blueprint for an object.<\/p>\n<p>This way you make the project once, and reuse it many times.<\/p>\n<p>In our code example before, consider that every string has the same behavior, the same attributes, so it only makes sense for strings to have a class <code>str<\/code> to define them.<\/p>\n<h2>Attributes and Methods<\/h2>\n<p>Objects have some behavior, this behavior is given by attributes and methods.<\/p>\n<p>In simple terms, in the context of an object, attributes are variables and methods are functions attached to an object.<\/p>\n<p>For example, a string has many built-in methods that we can use.<\/p>\n<p>They work like functions, you just need to them from the objects using a <code>.<\/code>.<\/p>\n<p>In this code snippet, I\\&#8217;m calling the <code>replace()<\/code> method from the string variable <code>my_city<\/code> which is an object, and instance of the class <code>str<\/code>.<\/p>\n<p>The <code>replace()<\/code> method replaces a part of the string for another and returns a new string with the change, the original string remains the same.<\/p>\n<p>Let\\&#8217;s replace \\&#8217;New\\&#8217; for \\&#8217;Old\\&#8217; in \\&#8217;New York\\&#8217;.<\/p>\n<pre><code class=\"language-python\">my_city = &#039;New York&#039;\nprint(my_city.replace(&#039;New&#039;, &#039;Old&#039;))\nprint(my_city)<\/code><\/pre>\n<pre><code>Old York\nNew York<\/code><\/pre>\n<h2>Creating a Class<\/h2>\n<p>We have used many objects (instances of classes) like strings, integers, lists, and dictionaries, all of them are instances of predefined classes in Python.<\/p>\n<p>To create our own classes we use the <code>class<\/code> keyword.<\/p>\n<p>By convention, the name of the class matches the name of the <code>.py<\/code> file and the module by consequence, it is also a good practice to organize the code.<\/p>\n<p>Create a file <code>vehicle.py<\/code> with the following class <code>Vehicle<\/code>.<\/p>\n<pre><code class=\"language-python\">class Vehicle:\n    def __init__(self, year, model, plate_number, current_speed = 0):\n        self.year = year\n        self.model = model\n        self.plate_number = plate_number\n        self.current_speed = current_speed\n\n    def move(self):\n        self.current_speed += 1\n\n    def accelerate(self, value):\n        self.current_speed += value\n\n    def stop(self):\n        self.current_speed = 0\n\n    def vehicle_details(self):\n        return &#039;Model: &#039; + self.model + &#039;, Year: &#039; + str(self.year) + &#039;, Plate: &#039; + self.plate_number<\/code><\/pre>\n<p>Let\\&#8217;s break down the class to explain it in parts.<\/p>\n<p>The <code>class<\/code> keyword is used to specify the name of the class <code>Vehicle<\/code>.<\/p>\n<p>The <code>&lt;strong&gt;init&lt;\/strong&gt;<\/code> function is a built-in function that all classes have, it is called when an object is created and is often used to initialize the attributes, assigning values to them, similar to what is done to variables.<\/p>\n<p>The first parameter <code>self<\/code> in the <code>&lt;strong&gt;init&lt;\/strong&gt;<\/code> function is a reference to the object (instance) itself, we call it <code>self<\/code> by convention and it has to be the first parameter in every instance method, as you can see in the other method definitions <code>def move(self)<\/code>, <code>def accelerate(self, value)<\/code>, <code>def stop(self)<\/code>, and <code>def vehicle_details(self)<\/code>.<\/p>\n<p><code>Vehicle<\/code> has 5 attributes: <code>year<\/code>, <code>model<\/code>, <code>plate_number<\/code>, and <code>current_speed<\/code>.<\/p>\n<p>Inside the <code>&lt;strong&gt;init&lt;\/strong&gt;<\/code>, each one of them is initialized with the parameters given when the object is instantiated.<\/p>\n<p>Notice that <code>current_speed<\/code> is initialized with <code>0<\/code> by default, meaning that if no value is given, <code>current_speed<\/code> will be equals to 0 when the object is first instantiated.<\/p>\n<p>Finally, we have three methods to manipulate our vehicle regarding its speed: <code>def move(self)<\/code>, <code>def accelerate(self, value)<\/code>, <code>def stop(self)<\/code>.<\/p>\n<p>And one method to give back information about the vehicle: <code>def vehicle_details(self)<\/code>.<\/p>\n<p>The implementation inside the methods work the same way as in functions, you can also have a <code>return<\/code> to give you back some value at the end of the method as demonstrated by <code>def vehicle_details(self)<\/code>.<\/p>\n<h2>Using the Class<\/h2>\n<p>Use the class on a terminal, import the <code>Vehicle<\/code> class from the <code>vehicle<\/code> module.<\/p>\n<p>Create an instance called <code>my_car<\/code>, initializing <code>year<\/code> with 2009, <code>model<\/code> with \\&#8217;F8\\&#8217;, <code>plate_number<\/code> with \\&#8217;ABC1234\\&#8217;, and <code>current_speed<\/code> with 100.<\/p>\n<p>The <code>self<\/code> parameter is not taken into consideration when calling methods, the Python interpreter infers its value as being the current object\/instance automatically, so we just have to pass the other arguments when instantiating and calling methods.<\/p>\n<p>Now use the methods to <code>move()<\/code> the car which increases its <code>current_speed<\/code> by 1, <code>accelerate()<\/code> which increases its <code>current_speed<\/code> by the value given in the argument, and <code>stop()<\/code> wich sets the <code>current_speed<\/code> to 0.<\/p>\n<p>Remember to print the value of <code>current_speed<\/code> at every interaction to see the changes.<\/p>\n<p>To finish the test, call <code>vehicle_details()<\/code> to print the information about our instantiated vehicle.<\/p>\n<pre><code class=\"language-python\">>&gt;&gt; from vehicle import Vehicle\n>&gt;&gt;\n>&gt;&gt; my_car = Vehicle(2009, &#039;F8&#039;, &#039;ABC1234&#039;, 100)\n>&gt;&gt; print(my_car.current_speed)\n100\n>&gt;&gt; my_car.move()\n>&gt;&gt; print(my_car.current_speed)\n101\n>&gt;&gt; my_car.accelerate(10)\n>&gt;&gt; print(my_car.current_speed)\n111\n>&gt;&gt; my_car.stop()\n>&gt;&gt; print(my_car.current_speed)\n0\n>&gt;&gt; print(my_car.vehicle_details())\nModel: F8, Year: 2009, Plate: ABC1234<\/code><\/pre>\n<p>If we don\\&#8217;t set the initial value for <code>current_speed<\/code>, it will be zero by default as stated before and demonstrated in the next example.<\/p>\n<pre><code class=\"language-python\">>&gt;&gt; from vehicle import Vehicle\n>&gt;&gt;\n>&gt;&gt; my_car = Vehicle(2009, &#039;F8&#039;, &#039;ABC1234&#039;)\n>&gt;&gt; print(my_car.current_speed)\n0\n>&gt;&gt; my_car.move()\n>&gt;&gt; print(my_car.current_speed)\n1\n>&gt;&gt; my_car.accelerate(10)\n>&gt;&gt; print(my_car.current_speed)\n11\n>&gt;&gt; my_car.stop()\n>&gt;&gt; print(my_car.current_speed)\n0\n>&gt;&gt; print(my_car.vehicle_details())\nModel: F8, Year: 2009, Plate: ABC1234<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is the 1st article in a series on Object-Oriented Programming: Classes and Objects in Python Object-Oriented Programming: Encapsulation in Python Inheritance in Python Object-Oriented Programming: Polymorphism in Python Classes and Objects are the fundamental concepts of Object-Oriented Programming. In Python, everything is an object! A variable (object) is just an instance of its type [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":742,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[6],"class_list":["post-1340","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Classes and Objects in Python<\/title>\n<meta name=\"description\" content=\"Learn the basic concepts of Object-Oriented Programming in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/renanmf.com\/classes-objects-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Classes and Objects in Python\" \/>\n<meta property=\"og:description\" content=\"Learn the basic concepts of Object-Oriented Programming in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/renanmf.com\/classes-objects-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Renan Moura - Software Engineering\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/renanmouraf\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-20T15:30:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-06T17:43:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/02\/fig-27-02-2020_21-01-52.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"1200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Renan Moura\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/renanmouraf\" \/>\n<meta name=\"twitter:site\" content=\"@renanmouraf\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Renan Moura\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/\"},\"author\":{\"name\":\"Renan Moura\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/person\\\/1a6fd46256318d200c1c8a867448e5a8\"},\"headline\":\"Classes and Objects in Python\",\"datePublished\":\"2020-04-20T15:30:37+00:00\",\"dateModified\":\"2021-09-06T17:43:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/\"},\"wordCount\":775,\"publisher\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/fig-27-02-2020_21-01-52.jpg\",\"keywords\":[\"python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/\",\"url\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/\",\"name\":\"Classes and Objects in Python\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/fig-27-02-2020_21-01-52.jpg\",\"datePublished\":\"2020-04-20T15:30:37+00:00\",\"dateModified\":\"2021-09-06T17:43:05+00:00\",\"description\":\"Learn the basic concepts of Object-Oriented Programming in Python.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/fig-27-02-2020_21-01-52.jpg\",\"contentUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/fig-27-02-2020_21-01-52.jpg\",\"width\":1800,\"height\":1200,\"caption\":\"how to python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/classes-objects-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/renanmf.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Classes and Objects in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#website\",\"url\":\"https:\\\/\\\/renanmf.com\\\/\",\"name\":\"Renan Moura - Software Engineering\",\"description\":\"Software development, machine learning\",\"publisher\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/renanmf.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#organization\",\"name\":\"Renan Moura\",\"url\":\"https:\\\/\\\/renanmf.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/me-e1583179172701.jpeg\",\"contentUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/me-e1583179172701.jpeg\",\"width\":120,\"height\":120,\"caption\":\"Renan Moura\"},\"image\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/renanmouraf\",\"https:\\\/\\\/x.com\\\/renanmouraf\",\"https:\\\/\\\/instagram.com\\\/renanmouraf\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/renanmouraf\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/person\\\/1a6fd46256318d200c1c8a867448e5a8\",\"name\":\"Renan Moura\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g\",\"caption\":\"Renan Moura\"},\"description\":\"I'm a Software Engineer working in the industry for a decade now. I like to solve problems with as little code as possible. I\u2019m interested in solving all sorts of problems with technology in creative and innovative ways. From everyday shell scripts to machine learning models. I write about Software Development, Machine Learning, and Career in tech.\",\"sameAs\":[\"https:\\\/\\\/renanmf.com\\\/\",\"https:\\\/\\\/www.instagram.com\\\/renanmouraf\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/renanmouraf\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/renanmouraf\"],\"url\":\"https:\\\/\\\/renanmf.com\\\/author\\\/renanmoura\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Classes and Objects in Python","description":"Learn the basic concepts of Object-Oriented Programming in Python.","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:\/\/renanmf.com\/classes-objects-python\/","og_locale":"en_US","og_type":"article","og_title":"Classes and Objects in Python","og_description":"Learn the basic concepts of Object-Oriented Programming in Python.","og_url":"https:\/\/renanmf.com\/classes-objects-python\/","og_site_name":"Renan Moura - Software Engineering","article_publisher":"https:\/\/www.facebook.com\/renanmouraf","article_published_time":"2020-04-20T15:30:37+00:00","article_modified_time":"2021-09-06T17:43:05+00:00","og_image":[{"width":1800,"height":1200,"url":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/02\/fig-27-02-2020_21-01-52.jpg","type":"image\/jpeg"}],"author":"Renan Moura","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/renanmouraf","twitter_site":"@renanmouraf","twitter_misc":{"Written by":"Renan Moura","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/renanmf.com\/classes-objects-python\/#article","isPartOf":{"@id":"https:\/\/renanmf.com\/classes-objects-python\/"},"author":{"name":"Renan Moura","@id":"https:\/\/renanmf.com\/#\/schema\/person\/1a6fd46256318d200c1c8a867448e5a8"},"headline":"Classes and Objects in Python","datePublished":"2020-04-20T15:30:37+00:00","dateModified":"2021-09-06T17:43:05+00:00","mainEntityOfPage":{"@id":"https:\/\/renanmf.com\/classes-objects-python\/"},"wordCount":775,"publisher":{"@id":"https:\/\/renanmf.com\/#organization"},"image":{"@id":"https:\/\/renanmf.com\/classes-objects-python\/#primaryimage"},"thumbnailUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/02\/fig-27-02-2020_21-01-52.jpg","keywords":["python"],"articleSection":["Python"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/renanmf.com\/classes-objects-python\/","url":"https:\/\/renanmf.com\/classes-objects-python\/","name":"Classes and Objects in Python","isPartOf":{"@id":"https:\/\/renanmf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/renanmf.com\/classes-objects-python\/#primaryimage"},"image":{"@id":"https:\/\/renanmf.com\/classes-objects-python\/#primaryimage"},"thumbnailUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/02\/fig-27-02-2020_21-01-52.jpg","datePublished":"2020-04-20T15:30:37+00:00","dateModified":"2021-09-06T17:43:05+00:00","description":"Learn the basic concepts of Object-Oriented Programming in Python.","breadcrumb":{"@id":"https:\/\/renanmf.com\/classes-objects-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/renanmf.com\/classes-objects-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/renanmf.com\/classes-objects-python\/#primaryimage","url":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/02\/fig-27-02-2020_21-01-52.jpg","contentUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/02\/fig-27-02-2020_21-01-52.jpg","width":1800,"height":1200,"caption":"how to python"},{"@type":"BreadcrumbList","@id":"https:\/\/renanmf.com\/classes-objects-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/renanmf.com\/"},{"@type":"ListItem","position":2,"name":"Classes and Objects in Python"}]},{"@type":"WebSite","@id":"https:\/\/renanmf.com\/#website","url":"https:\/\/renanmf.com\/","name":"Renan Moura - Software Engineering","description":"Software development, machine learning","publisher":{"@id":"https:\/\/renanmf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/renanmf.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/renanmf.com\/#organization","name":"Renan Moura","url":"https:\/\/renanmf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/renanmf.com\/#\/schema\/logo\/image\/","url":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/03\/me-e1583179172701.jpeg","contentUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/03\/me-e1583179172701.jpeg","width":120,"height":120,"caption":"Renan Moura"},"image":{"@id":"https:\/\/renanmf.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/renanmouraf","https:\/\/x.com\/renanmouraf","https:\/\/instagram.com\/renanmouraf","https:\/\/www.linkedin.com\/in\/renanmouraf\/"]},{"@type":"Person","@id":"https:\/\/renanmf.com\/#\/schema\/person\/1a6fd46256318d200c1c8a867448e5a8","name":"Renan Moura","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g","caption":"Renan Moura"},"description":"I'm a Software Engineer working in the industry for a decade now. I like to solve problems with as little code as possible. I\u2019m interested in solving all sorts of problems with technology in creative and innovative ways. From everyday shell scripts to machine learning models. I write about Software Development, Machine Learning, and Career in tech.","sameAs":["https:\/\/renanmf.com\/","https:\/\/www.instagram.com\/renanmouraf\/","https:\/\/www.linkedin.com\/in\/renanmouraf\/","https:\/\/x.com\/https:\/\/twitter.com\/renanmouraf"],"url":"https:\/\/renanmf.com\/author\/renanmoura\/"}]}},"_links":{"self":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts\/1340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/comments?post=1340"}],"version-history":[{"count":10,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts\/1340\/revisions"}],"predecessor-version":[{"id":3803,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts\/1340\/revisions\/3803"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/media\/742"}],"wp:attachment":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/media?parent=1340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/categories?post=1340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/tags?post=1340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}