<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: James Hubert</title>
    <description>The latest articles on DEV Community by James Hubert (@jameshubert_com).</description>
    <link>https://dev.to/jameshubert_com</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F173444%2F3b245912-8a58-4a8e-b49f-b34f6e842f4d.jpeg</url>
      <title>DEV Community: James Hubert</title>
      <link>https://dev.to/jameshubert_com</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jameshubert_com"/>
    <language>en</language>
    <item>
      <title>12 Products in 12 Months - Starting today</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Sun, 06 Jul 2025 14:52:55 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/12-products-in-12-months-starting-today-4b8j</link>
      <guid>https://dev.to/jameshubert_com/12-products-in-12-months-starting-today-4b8j</guid>
      <description>&lt;h2&gt;
  
  
  Background: The Long Tail Effects of Cowardice
&lt;/h2&gt;

&lt;p&gt;Hi friends. It's James again. Today is my birthday and I feel I don't have a lot to show for it. Five years ago, in 2020 I posted on Dev.to about creating 100 React projects in 100 days (&lt;a href="https://dev.to/jameshubert_com/100-days-of-react-1h5d"&gt;link here&lt;/a&gt;) to learn front end development and get a full time job in the industry.&lt;/p&gt;

&lt;p&gt;That mini-marathon of React projects got me some retweets from indie dev sites and the Dev.to community, and a little notoriety in the self-taught Javascript learner space. The projects repo (&lt;a href="https://github.com/jwhubert91/100daysofreact" rel="noopener noreferrer"&gt;link&lt;/a&gt;) has 94 stars on it and 44 forks, which is cool, I also eventually did get a full time software engineering job at a startup, in part because someone in my network had seen the posts. It led to some really fruitful things and a whole career in the industry, plus eventually a web development business that 100% financially supported me while I lived abroad.&lt;/p&gt;

&lt;p&gt;But honestly I've been thinking of building digital products since I was 19- 15 years ago- and I've never done it. In large part because I didn't have the skills, but mostly because I didn't have the guts. Rather than drop out of college and learn app development like I wanted to after my first visit to the Bay Area in 2011, I stayed in college because I didn't have the guts.&lt;/p&gt;

&lt;p&gt;Rather than drop everything, be poor for a while, and learn to code after college like I wanted to in 2014 I went into software sales because I didn't have the guts. Rather than go full-time on a startup idea in 2015 like I wanted to, when I started learning Swift, I stayed working full-time because I didn't have the guts. And over the last four and a half years since I made those React projects to learn to code in 2020 I never made any of the products I wanted to build because I wanted to get a software engineering job and feel validated instead, because I didn't have the guts.&lt;/p&gt;

&lt;p&gt;Well I'm a lot more competent with code now. I know React + NextJS and styling tools like Tailwind pretty reflexively. Deployment is a breeze and so is CI/CD. I also know Flutter for mobile dev pretty well at this point. So there's no reason to avoid it any longer. Plus I have a job and can financially support myself which, frankly, is a big deal when you're trying to confidently contribute to your side projects.&lt;/p&gt;

&lt;p&gt;Today I'm starting 12 products in 12 months, something I honestly thought about doing all the way back in 2020 and has been bouncing around my head since then. Most of what I plan to make has also been with me that long, or are things I've thought of over the years since. It's time to put these things out into the wild.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, What Is A Product?
&lt;/h2&gt;

&lt;p&gt;What is a product? Let's define our terms. A product is something that exists in the world which people can purchase. So unlike the React projects, if the project isn't complete and if it can't accept payment then I've failed. That's why I'm giving myself a whole month per project rather than just a day 😉&lt;/p&gt;

&lt;p&gt;And a product has to be a complete service. Whatever it claims to provide, it does its damned best to provide it to keep its users happy and keep them coming back. In this realm we go from incomplete best-effort &lt;strong&gt;&lt;em&gt;projects&lt;/em&gt;&lt;/strong&gt; to minimum viable &lt;strong&gt;&lt;em&gt;products&lt;/em&gt;&lt;/strong&gt;. So that's the definition. They definitely don't have to be perfect, but if they aren't feature-complete, then it doesn't count.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first product - Texas Trades
&lt;/h2&gt;

&lt;p&gt;Link - &lt;a href="https://www.gotexastrades.com" rel="noopener noreferrer"&gt;www.gotexastrades.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OK, what am I building between this very moment and August?&lt;/p&gt;

&lt;p&gt;The first product I have already been working on is a mobile-first service which is a Linkedin alternative for the fast growing blue collar industry, focused on the booming Texas job market. I've thought a lot about this over the last few years. I even considered buying the domain &lt;em&gt;whythetrades.com&lt;/em&gt; way back in 2019 when I first started thinking about this:&lt;/p&gt;

&lt;p&gt;I've often wondered why high paying, stable blue collar jobs are considered so much less prestigious in the US than jobs that pay a lot less and are frankly easier that require a college degree. In countries like Germany and Canada, the trades and white collar work are treated with similar reverence. You're working afterall- and providing a valuable service. That's prestigious and awesome in itself.&lt;/p&gt;

&lt;p&gt;Plus, the job market is changing. With AI coming to displace the white collar world, college degrees not paying anywhere near what they used to, and the very real phenomena of &lt;a href="https://techcrunch.com/2025/07/03/who-is-soham-parekh-the-serial-moonlighter-silicon-valley-startups-cant-stop-hiring/" rel="noopener noreferrer"&gt;US companies farming out their creative tasks to highly capable overseas workers willing to work for less&lt;/a&gt;, I think smart Americans will start to understand that prestige of a job and its market value aren't really aligned in 2025, and to take the trades seriously.&lt;/p&gt;

&lt;p&gt;A very real question exists- why would someone take out $200k in student loans just to get a $50k per year job four years later if they can join an apprenticeship when they're 18, accrue zero debt, and be making &lt;a href="https://ibew46.com/media/7863/020325-080325wire_wage_sheetv10.pdf" rel="noopener noreferrer"&gt;well over six figures &lt;/a&gt; before they're 23 years old?&lt;/p&gt;

&lt;p&gt;So that's what I'm working on. A professional network for blue collar folks who maybe have never owned a computer, possibly never even made a resume, never had a Linkedin or don't want to read inspirational articles about digital marketing when they're bending a pipe or lifting a steel girder. But the main thing that I think these people deserve- a job board that doesn't require you to write your own resume with Microsoft Word and doesn't force you to create an individual account per application, and fill out a 10 page Workday or Oracle form with 90% of the same answers every time. This process should be eradicated and the companies who use those HR tools should be ashamed. Here are some screenshots from the UI I've got done so far:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87k1ksaif7a1axaab7r4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87k1ksaif7a1axaab7r4.png" alt="Logo courtesy of Chatgpt" width="800" height="1518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyf2u74s6exf8tp8dg83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyf2u74s6exf8tp8dg83.png" alt="Experience section of the profile screen" width="800" height="1518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Inspiration
&lt;/h2&gt;

&lt;p&gt;I won't lie to you, and those in the indie maker space probably already know I'm copying the 12 products idea from famous indie hacker &lt;a href="https://levels.io/12-startups-12-months/" rel="noopener noreferrer"&gt;Pieter Levels&lt;/a&gt;. It's just coincidental that I also heard about and was inspired to make my 2020 list of React projects from &lt;a href="https://jenniferdewalt.com/?ref=levels.io" rel="noopener noreferrer"&gt;Jennifer Dewalt's 120 websites in 120 days&lt;/a&gt; and I've been following his career since 2022.&lt;/p&gt;

&lt;p&gt;I have a separate problem from Pieter though, which is a bone to pick with my own mind. I've had hundreds of ideas over the course of my professional life and have hardly made any of them. This is ridiculous and has led to me being a dreamer rather than a doer, which no one wants to be. And I'm too old now to be walking around with a bunch of ideas that are exciting that I've made no progress on. That's how you get old- not taking action. As Thoreau once wrote, "The youth gets together his materials to build a bridge to the moon, or, perchance, a palace or temple on the earth, and, at length, the middle-aged man concludes to build a woodshed". So I'm taking action to get out of that hole.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Process
&lt;/h2&gt;

&lt;p&gt;Simple. Each Sunday night I write a blog post documenting my progress on whatever product I'm working on. My KPI's are documented each week with a binary checkbox:&lt;br&gt;
✅ Shipped?&lt;br&gt;
✅ Marketed?&lt;br&gt;
✅ Accepts Payments?&lt;br&gt;
✅ Collected Feedback?&lt;br&gt;
✅ 2nd Version Shipped?&lt;/p&gt;

&lt;p&gt;I'll also be using the handy tool WIP.co - a maker tool for developers to track their progress. Here's my link over there:&lt;br&gt;
&lt;a href="https://wip.co/@well_akshually" rel="noopener noreferrer"&gt;https://wip.co/@well_akshually&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Wish me luck!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My last project for 100 React projects in 100 days</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Tue, 23 Apr 2024 16:36:40 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/my-last-project-for-100-react-projects-in-100-days-2el8</link>
      <guid>https://dev.to/jameshubert_com/my-last-project-for-100-react-projects-in-100-days-2el8</guid>
      <description>&lt;p&gt;&lt;em&gt;Hey! I'm on a mission to make 100 React.js projects. Please follow my dev.to profile or my &lt;a href="https://www.twitter.com/jameshubert_com"&gt;twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Link to today's deployed app: &lt;a href="https://portful.co/"&gt;Link&lt;/a&gt;&lt;br&gt;
Link to the repo: &lt;a href="https://github.com/jwhubert91/portfolio-site"&gt;github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm writing you today to talk about failure, and the nature of success. I don't feel bad about it. There are people out there who believe in positivity like a religion (they are mostly in sales and marketing), they do not like to acknowledge failure. They fake it til they make it and see themselves as being perpetually better than all competition as a mindset (a.k.a. a "&lt;a href="https://www.urbandictionary.com/define.php?term=Grindset"&gt;grindset&lt;/a&gt;").&lt;/p&gt;

&lt;p&gt;That is not me. I am grounded in reality and believe in plain speaking. And all roads to success are paved with failure.&lt;/p&gt;

&lt;p&gt;On Halloween of 2020 at the height of the pandemic in New York City I sat alone in my Brooklyn apartment and dedicated myself to doing 100 React projects in 100 days. It was one of the harder things I had ever done, but I knew it would force me to learn. Every day I made a new project in React, usually based on some concept I was learning in tutorials or on Youtube or from a blog, then I would blog about it.&lt;/p&gt;

&lt;p&gt;The whole process probably took about 4 hours per day on average. Both the projects and the blog posts ended up taking equally large amounts of time. For this reason eventually (around project 25 I believe) the space between projects slowed from every day to every other day, and so on.&lt;/p&gt;

&lt;p&gt;In this time I also ended up getting referred to a full time job and around project 80 I basically stopped doing the projects altogether. So now, 3 and a half years later I'm writing the final blog post for the 100 projects. Better to finish something you've started than not, even if it's late, no?&lt;/p&gt;

&lt;p&gt;The last project I made in React, which I actually made about a year and a half ago in the fall of 2022, was called Portful.co. It is a React project with Context API, Typescript, Firebase, and hosted on Netlify. The idea was to make a space online where developers and creatives could display their portfolio easily and elegantly without having to buy a domain and code their own website. I still think it's a good idea, but this project wasn't it.&lt;/p&gt;

&lt;p&gt;At the end of the project I tested, launched it, and after over a month of working on it realized that not only was it poorly styled and not a great substitute for hosting online creative work, but also that Create React App apps have no SEO ability. Even after working on React for multiple years it had never dawned on me that React alone was literally a "Single Page Application". It's technically only one page with different Javascript components being showed in a page-like manner to users. But search engines can only index actual pages.&lt;/p&gt;

&lt;p&gt;After probably 150 hours of work I gave up and abandoned all hope. A friend who is a senior developer mentioned that this is why people use NextJS or Gatsby.&lt;/p&gt;

&lt;p&gt;It's pretty funny that after all that time working on React, and even passing coding interviews and having a full-time job, since I'd never tried to build a real product before I'd never thought of the ramifications of a lack of SEO. Previously, I had thought SEO was for marketers, and I wanted nothing to do with it.&lt;/p&gt;

&lt;p&gt;Still though, in building the project I learned about all the time it takes to actually launch a new site that was (close to) complete. It has auth, a database, routing, and I actually got a few people to use it although they abandoned it quickly.&lt;/p&gt;

&lt;p&gt;I also likely became a better developer. Building out request-response cycles and storing the successfully queries in local state became second nature.&lt;/p&gt;

&lt;p&gt;To summarize the 100 projects as a whole, although completing it in 100 days was a failure, I did learn a ton through practice and experience- something tutorials can never teach you. And in the process of writing thoughtful blog posts, I was forced to communicate the concepts learned which also feeds into learning. If I could do it all over again, I would. Though next time I take on something like this I'll stick to the time limit I do it in.&lt;/p&gt;

&lt;p&gt;If you're interested in pursuing something like this, I recommend you go for it. There's nothing stopping you. By publishing your projects publicly you get social accountability, and by completing it you learn what you're made of. Most of all, by setting hard goals and attempting to achieve them, you learn about both the technology you're practicing and yourself through failure- which is the greatest teacher.&lt;/p&gt;

&lt;p&gt;Thanks to everyone who supported me along the way. There's much more to come 🙏&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgg6acmsxp46nx9u3m367.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgg6acmsxp46nx9u3m367.jpeg" alt="Yoda on failure" width="736" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/jameshubert_com"&gt;@jameshubert_com&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Intro to Python: Day 19 - Building a Dictionary</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Tue, 29 Aug 2023 14:35:00 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-19-building-a-dictionary-28he</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-19-building-a-dictionary-28he</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Dictionaries are an essential building block in programming and a fundamental data type in most languages. In Python, we can build a dictionary simply by declaring an empty one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;state_population_dict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then add to it by explicitly naming a key-value pair. Here we are adding states to our &lt;code&gt;state_population_dict&lt;/code&gt; dictionary with their respective populations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;state_population_dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;WA&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7739000&lt;/span&gt;
&lt;span class="n"&gt;state_population_dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;NY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;19840000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then check the value of a key in the dictionary simply by calling the dictionary with the key in brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state_population_dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;WA&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="c1"&gt;# prints 7739000
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we try to check the value of a key that does not exist on the dictionary, we will get a &lt;code&gt;KeyError&lt;/code&gt; which states the key does not exist on the dictionary.&lt;/p&gt;

&lt;p&gt;To check if a key exists on the dictionary before requesting to get its value, we can use the &lt;code&gt;in&lt;/code&gt; keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TX&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;state_population_dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state_population_dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TX&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TX population not in dictionary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Intro to Python: Day 18 - Running Your First Python Program</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Mon, 28 Aug 2023 12:57:00 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-18-running-your-first-python-program-321b</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-18-running-your-first-python-program-321b</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To run a program in Python, luckily it's quite a bit easier than learning to run your first program in Javascript, for which you have to learn Node.&lt;/p&gt;

&lt;p&gt;Simply make sure Python is installed on your computer by opening a terminal and typing &lt;code&gt;python&lt;/code&gt; or on Mac/Linux systems it is likely &lt;code&gt;python3&lt;/code&gt;, which it is for me. If you get an error, go to the Python website and download it to your machine. Once installed, running &lt;code&gt;python3&lt;/code&gt; should print the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Python&lt;/span&gt; &lt;span class="mf"&gt;3.9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Oct&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Clang&lt;/span&gt; &lt;span class="mf"&gt;14.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clang&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1400.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;29.202&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;darwin&lt;/span&gt;
&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;help&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;copyright&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;credits&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;license&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run your own Python program simply create a folder, and save a Python file in it by using the extension &lt;code&gt;.py&lt;/code&gt;. For example, &lt;code&gt;main.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's start traditionally and write a Hello World program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#main.py
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello world!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you save this program and in the command line run &lt;code&gt;python3 main.py&lt;/code&gt; from the project directory, your string will print to the screen. Huzzah!&lt;/p&gt;

&lt;p&gt;This means it is installed and the three &lt;code&gt;&amp;gt;&lt;/code&gt; mean it can accept input. You can stop the interpreter by pressing CTRL + D on a Mac.&lt;/p&gt;

&lt;p&gt;When you verify Python is installed (&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Intro to Python: Day 17 - Making Dumb Mistakes with Lists []</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Thu, 24 Aug 2023 12:36:36 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-17-making-dumb-mistakes-with-lists--phi</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-17-making-dumb-mistakes-with-lists--phi</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One of the things I've found most helpful about Python so far is the error messages. Whenever your program crashes, you get a full traceback message of all the places in the code where the program failed.&lt;/p&gt;

&lt;p&gt;If you scroll to the bottom of the traceback, you'll see the first place in the code it failed- which is the first bug it encountered that needs to be fixed. Python will also try to print out an exception that indicates what kind of bug it encountered.&lt;/p&gt;

&lt;p&gt;Today I encountered an IndexError while testing my program. Unlike Javascript, which will allow you to create a list by explicitly adding elements at a given index, Python is more strict, and will only allow this if the index already exists. This means that unlike in Javascript, the following Python code will crash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;my_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;apple&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;my_list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# console will print:
# ERROR!
# Traceback (most recent call last):
#  ...
# IndexError: list assignment index out of range
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is because although the &lt;code&gt;my_list&lt;/code&gt; list exists, there is no index 0 on it, so in Python we cannot simply add something there if it doesn't exist.&lt;/p&gt;

&lt;p&gt;Javascript is more forgiving because it's made for working with browsers and the web. It does its best to help you. Python will not, but that's ok, because it's more frequently used for backend computations and more precise programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Intro to Python: Day 16 - OOP - Overriding ==, &gt;, and &lt;</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Wed, 23 Aug 2023 13:22:24 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-16-oop-overloading-and--59nl</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-16-oop-overloading-and--59nl</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Today we follow up on &lt;a href="https://dev.to/jwhubert91/intro-to-python-day-15-oop-overloading-the-print-method-on-a-custom-class-ljm"&gt;yesterday's post&lt;/a&gt; about overloading the built-in print method. This time, we're overloading &lt;code&gt;==&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;&lt;/code&gt; operators.&lt;/p&gt;

&lt;p&gt;It's always useful to be able to compare things, and it's somewhat natural that two instances of the same class might be able to be compared. But the built-in functionality for those operators is to compare either numbers or strings, not classes.&lt;/p&gt;

&lt;p&gt;Let's say we are a car dealership and we want a program that can help us figure out quickly what the value of different cars is. We want to just quickly compare them.&lt;/p&gt;

&lt;p&gt;Obviously if I create a &lt;code&gt;Car&lt;/code&gt; class and then compare two instances of that class, we'll just get an error. Like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;make&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;

&lt;span class="n"&gt;mustang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ford&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mustang&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;camaro&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Chevy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Camaro&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mustang&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;camaro&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Will print the following:
# ERROR!
# Traceback (most recent call last):
#  File "&amp;lt;string&amp;gt;", line 12, in &amp;lt;module&amp;gt;
# TypeError: '&amp;gt;' not supported between instances of 'Car' and # 'Car'
&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So to create method on this class that overrides the built-in functionality so that we can compare these &lt;code&gt;Car&lt;/code&gt; class instances, let's use the built-in &lt;code&gt;eq&lt;/code&gt;, &lt;code&gt;gt&lt;/code&gt;, and &lt;code&gt;lt&lt;/code&gt; methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;#...
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__eq__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__gt__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;__eq__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
        &lt;span class="nf"&gt;elif &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__lt__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;__eq__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
        &lt;span class="nf"&gt;elif &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;__gt__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using the built-in &lt;code&gt;eq&lt;/code&gt;, &lt;code&gt;gt&lt;/code&gt;, and &lt;code&gt;lt&lt;/code&gt; keywords we can tap into this functionality and define our own behavior for &lt;code&gt;==&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So now if we compare two cars:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;mustang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ford&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Mustang&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;camaro&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Chevy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Camaro&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mustang&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;camaro&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mustang&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;camaro&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mustang&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;camaro&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get the result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;True
False
False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>Intro to Python: Day 15 - OOP - Overriding the Print Method on a Custom Class</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Tue, 22 Aug 2023 13:00:26 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-15-oop-overloading-the-print-method-on-a-custom-class-ljm</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-15-oop-overloading-the-print-method-on-a-custom-class-ljm</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So every programming language has its own built-in behavior for printing different kinds of objects. In Python, if you have a custom class, printing an instance of the class will simply print a pointer which indicates its place in your storage. It's pretty useless.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;

&lt;span class="n"&gt;lion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lion&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lion&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# prints "&amp;lt;Lion object at 0xa0acf8&amp;gt;"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Note: This example is adapted from the super duper helpful OOP course at dev.to)&lt;/p&gt;

&lt;p&gt;So, if we want to override the built-in print functionality, all we need to do is specify it using the built-in instance method &lt;code&gt;__str__()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__str__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I am a &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; type of animal.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;lion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lion&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lion&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# prints "I am a lion type of animal."
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty cool eh? If you're working extensively with custom classes, having them be able to show useful information when printed can be useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Intro to Python: Day 14 - OOP - Method signatures in polymorphism</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Mon, 21 Aug 2023 14:32:04 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-14-oop-method-signatures-in-polymorphism-33pl</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-14-oop-method-signatures-in-polymorphism-33pl</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We're following up on &lt;a href="https://dev.to/jwhubert91/intro-to-python-day-13-oop-what-is-polymorphism-46fd"&gt;yesterday's article on polymorphism&lt;/a&gt; with a brief discussion of function and method signatures and best practices in Python inheritance.&lt;/p&gt;

&lt;p&gt;As discussed, polymorphism is the ability for multiple different classes, with different methods and data, to inherit from the same parent class. This makes it easier to create new classes that share methods that are on the parent.&lt;/p&gt;

&lt;p&gt;In computer programming, a &lt;strong&gt;function signature&lt;/strong&gt; is a term for the inputs and outputs of a function. To use the &lt;a href="https://boot.dev"&gt;boot.dev&lt;/a&gt; definition in OOP Chapter 5 on Polymorphism:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A function signature includes the name, inputs, and outputs of a function or method.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In functional programming, each function is recognized to have its own distinct function signature, and there is no inheritance as such. In OOP, inheritance is one of the major benefits.&lt;/p&gt;

&lt;p&gt;This means we need to take care though not to confuse users of our code, especially when overriding methods on child classes. So, it is a best practice NOT to change the method signature of a class method which inherits from a parent, even when overriding the method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Intro to Python: Day 13 - OOP - What is polymorphism? 🧐</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Sun, 20 Aug 2023 13:33:47 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-13-oop-what-is-polymorphism-46fd</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-13-oop-what-is-polymorphism-46fd</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Today we follow up on a series of posts about Object Oriented Programming in Python. You can check out yesterday's article &lt;a href="https://dev.to/jwhubert91/intro-to-python-day-12-oop-calling-a-parent-method-36g9"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We've been talking about inheritance in OOP recently, and yesterday's blog post discussed how a child class can inherit variables and methods from a parent class. This is useful if you want the same behavior in a child that a parent has.&lt;/p&gt;

&lt;p&gt;But what if you want different behavior in the child class than a parent has, but want to inherit everything else? This is where &lt;strong&gt;polymorphism&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;p&gt;Let's say you have an &lt;code&gt;Organism&lt;/code&gt; class. Just like in biology, all animals and plants are types of organisms. So we might have a &lt;code&gt;eat()&lt;/code&gt; method on the organism class (all organisms like to eat!).&lt;/p&gt;

&lt;p&gt;On the parent &lt;code&gt;Organism&lt;/code&gt; class the eat method look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Organism&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;calories&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; ate a meal of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;calories&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; calories&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above class, we have a constructor function where we can pass in a name and an instance variable &lt;code&gt;name&lt;/code&gt; that we set it to. So now our organism has a name! In the &lt;code&gt;eat&lt;/code&gt; method, we pass in a number of calories and our method prints out how many calories it ate.&lt;/p&gt;

&lt;p&gt;Let's say our organism is a plant. Plants don't eat food like you and I do, instead they get their food from the sun and convert it to energy. So eating calories doesn't make sense for a &lt;code&gt;Plant&lt;/code&gt; class, even if it inherits from the &lt;code&gt;Organism&lt;/code&gt; class. So instead we want to inherit everything else from &lt;code&gt;Organism&lt;/code&gt; but the &lt;code&gt;eat()&lt;/code&gt; method should accept a &lt;code&gt;hours_of_sunlight&lt;/code&gt; argument instead of &lt;code&gt;calories&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;Plant&lt;/code&gt; class might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Plant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Organism&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hours_of_sunlight&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; plant converted &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hours_of_sunlight&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; hours of sunlight into energy!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the &lt;code&gt;Plant&lt;/code&gt; class calls the parent's constructor function using &lt;code&gt;super().__init__()&lt;/code&gt; in its constructor, thereby inheriting the &lt;code&gt;name&lt;/code&gt; variable and setting it, which is awesome!. We also set a new instance variable called &lt;code&gt;type&lt;/code&gt; where we can pass in things like "palm tree" or "sunflower" or "green ivy".&lt;/p&gt;

&lt;p&gt;After creating an instance of &lt;code&gt;Plant&lt;/code&gt; the &lt;code&gt;eat&lt;/code&gt; method would be available on it the instance because it would come from the parent. But as we said we want the &lt;code&gt;Plant&lt;/code&gt; class' &lt;code&gt;eat&lt;/code&gt; method to be different! So to do this we simply create a &lt;em&gt;new&lt;/em&gt; method on the &lt;code&gt;Plant&lt;/code&gt; class with the same name- &lt;code&gt;eat()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, when an instance of &lt;code&gt;Plant&lt;/code&gt; is created and its &lt;code&gt;eat&lt;/code&gt; method is called, instead of printing a line about how many calories it consumed, we describe how many hours of sunlight it converted into energy!&lt;/p&gt;

&lt;p&gt;This ability to selectively inherit data and methods from the parent but also &lt;strong&gt;take on a new form&lt;/strong&gt; if need be, by overwriting methods and variables inherited from the parent, is called &lt;strong&gt;polymorphism&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Intro to Python: Day 12 - OOP - Calling a parent method</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Sun, 20 Aug 2023 03:22:44 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-12-oop-calling-a-parent-method-36g9</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-12-oop-calling-a-parent-method-36g9</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Today is another article on the concept of Object Oriented Programming in Python.&lt;/p&gt;

&lt;p&gt;The fact that a child class can inherit data through variables, and actions through methods, from a parent class is a main reason why OOP is powerful. This is called single inheritance and refers to a direct relationship from parent to child class.&lt;/p&gt;

&lt;p&gt;In order for a child component to inherit a parent component's methods, you must first instantiate the child Class with the parent's constructor using the &lt;code&gt;super()&lt;/code&gt; method. For example, let's say a Truck class inherits from a Vehicle class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_color&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Truck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;horsepower&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;horsepower&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;horsepower&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we see that we use the &lt;code&gt;super()&lt;/code&gt; method to call the parent's constructor function. But this method is built in. Now let's say we want to get the color of the truck using the parent's &lt;code&gt;get_color()&lt;/code&gt; method. In order to call it, we must use the &lt;code&gt;super()&lt;/code&gt; method again, but this time for a non-built-in method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Truck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;horsepower&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;horsepower&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;horsepower&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;compliment_car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;truck_color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;get_color&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hey love that &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;truck_color&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; truck you have!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how we can use the parent Vehicle's get_color() method on the child Truck class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Intro to Python: Day 11 - Another Class Inheritance Example</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Thu, 17 Aug 2023 13:41:38 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-11-another-class-inheritance-example-29o6</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-11-another-class-inheritance-example-29o6</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Today in my journey with boot.dev I encountered a fun problem that we solved using OOP and class-based inheritance.&lt;/p&gt;

&lt;p&gt;A rectangle is a shape with four sides where the length of the sides is equal and the length of the top and bottom are equal, but the top and bottom don't need to be equal to the length of the sides.&lt;/p&gt;

&lt;p&gt;A square is a type of rectangle, but all four sides must be the same length.&lt;/p&gt;

&lt;p&gt;So, if we make a &lt;code&gt;Rectangle&lt;/code&gt; class to get the perimeter and area of any given rectangle, where we need to input the length of the x-axis sides and the length of the y-axis sides in order to get that information, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_perimeter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...then we should be able to quickly build a &lt;code&gt;Square&lt;/code&gt; class that inherits these methods but is automatically instantiated using only the length of one of its sides (since all sides of a square are the same length):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Behold, the power of OOP! Unlike dragons and cars and other fairly non-sensical use cases, I could see actually using something like this if I were, say, building a house, maybe. Idk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>oop</category>
    </item>
    <item>
      <title>Intro to Python: Day 10 - Basic Operators in Python vs Javascript</title>
      <dc:creator>James Hubert</dc:creator>
      <pubDate>Mon, 14 Aug 2023 00:11:02 +0000</pubDate>
      <link>https://dev.to/jameshubert_com/intro-to-python-day-10-basic-operators-in-python-vs-javascript-516m</link>
      <guid>https://dev.to/jameshubert_com/intro-to-python-day-10-basic-operators-in-python-vs-javascript-516m</guid>
      <description>&lt;p&gt;&lt;em&gt;Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or &lt;a href="https://twitter.com/stonestwebdev"&gt;my twitter&lt;/a&gt; for updates and feel free to reach out if you have questions. Thanks for your support!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As a developer with a basic background in Javascript, it can be confusing at times learning Python and completing exercises in a course because the syntax is so readable in Python, and so similar to JS, but not the same.&lt;/p&gt;

&lt;p&gt;Every development language will have logical operators, and they will follow a simple AND, OR, NOT syntax.&lt;/p&gt;

&lt;p&gt;In my native Javascript however, AND is demarcated with &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, OR is demarcated with &lt;code&gt;||&lt;/code&gt; and NOT is demarcated with &lt;code&gt;!&lt;/code&gt;. These are readable and short. They're so easy to get used to it can be tough to transition out, especially when Python's logical operators &lt;code&gt;==&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt; and so on are nearly identical to Javascript's.&lt;/p&gt;

&lt;p&gt;In Python, those operators are simple English: &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt;, &lt;code&gt;not&lt;/code&gt;. They're so simple it's easy to forget them! Which is the easiest way to get a bug you have no idea how to solve.&lt;/p&gt;

&lt;p&gt;Onward and upward!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you like projects like this and want to stay up to date with more, check out my Twitter &lt;a href="https://twitter.com/stonestwebdev"&gt;@stonestwebdev&lt;/a&gt;, I follow back! See you tomorrow for another project.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
