<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>Real Python</title>
  <link href="https://realpython.com/atom.xml" rel="self"/>
  <link href="https://realpython.com/"/>
  <updated>2024-03-22T12:00:00+00:00</updated>
  <id>https://realpython.com/</id>
  <author>
    <name>Real Python</name>
  </author>

  
    <entry>
      <title>The Real Python Podcast – Episode #197: Using Python in Bioinformatics and the Laboratory</title>
      <id>https://realpython.com/podcasts/rpp/197/</id>
      <link href="https://realpython.com/podcasts/rpp/197/"/>
      <updated>2024-03-22T12:00:00+00:00</updated>
      <summary>How is Python being used to automate processes in the laboratory? How can it speed up scientific work with DNA sequencing? This week on the show, Chemical Engineering PhD Student Parsa Ghadermazi is here to discuss Python in bioinformatics.</summary>
      <content type="html">
        &lt;p&gt;How is Python being used to automate processes in the laboratory? How can it speed up scientific work with DNA sequencing? This week on the show, Chemical Engineering PhD Student Parsa Ghadermazi is here to discuss Python in bioinformatics.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Build a Python Turtle Game: Space Invaders Clone</title>
      <id>https://realpython.com/build-python-turtle-game-space-invaders-clone/</id>
      <link href="https://realpython.com/build-python-turtle-game-space-invaders-clone/"/>
      <updated>2024-03-20T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll use Python&#x27;s turtle module to write a Space Invaders clone. You&#x27;ll learn about techniques used in animations and games, and consolidate your knowledge of key Python topics.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In this tutorial, you’ll use Python’s &lt;code&gt;turtle&lt;/code&gt; module to build a Space Invaders clone. The game &lt;a href=&quot;https://en.wikipedia.org/wiki/Space_Invaders&quot;&gt;Space Invaders&lt;/a&gt; doesn’t need any introduction. The original game was released in 1978 and is one of the most recognized video games of all time. It undeniably defined its own video game genre. In this tutorial, you’ll create a basic clone of this game.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;turtle&lt;/code&gt; module you’ll use to build the game is part of Python’s standard library, and it enables you to draw and move sprites on the screen. The &lt;code&gt;turtle&lt;/code&gt; module is not a game-development package, but it gives instructions about creating a &lt;em&gt;&lt;code&gt;turtle&lt;/code&gt; game&lt;/em&gt;, which will help you understand how video games are built.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Design and build&lt;/strong&gt; a classic video game&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;turtle&lt;/code&gt; module to &lt;strong&gt;create animated sprites&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;user interaction&lt;/strong&gt; in a graphics-based program&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create a game loop&lt;/strong&gt; to control each frame of the game&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use functions&lt;/strong&gt; to represent key actions in the game&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This tutorial is ideal for anyone who is familiar with the core Python topics and wants to use them to build a classic video game from scratch. You don’t need to be familiar with the &lt;code&gt;turtle&lt;/code&gt; module to work through this tutorial. You can download the code for each step by clicking on the link below:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-python-turtle-game-space-invaders-clone-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-python-turtle-game-space-invaders-clone-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to build a Python turtle game.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In the next section, you can have a look at the version of the game you’ll build as you follow the steps outlined in this tutorial.&lt;/p&gt;
&lt;h2 id=&quot;demo-a-python-turtle-space-invaders-game&quot;&gt;Demo: A Python Turtle Space Invaders Game&lt;a class=&quot;headerlink&quot; href=&quot;#demo-a-python-turtle-space-invaders-game&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You’ll build a simplified version of the classic Space Invaders game and control the laser cannon with the keys on your keyboard. You’ll shoot lasers from the cannon by pressing the spacebar, and aliens will appear at regular intervals at the top of the screen and move downwards. Your task is to shoot the aliens before they reach the bottom of the screen. The game ends when one alien reaches the bottom.&lt;/p&gt;
&lt;p&gt;This is what your &lt;code&gt;turtle&lt;/code&gt; game will look like when you complete this tutorial:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 &quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/920307157?background=1&quot; frameborder=&quot;0&quot; allow=&quot;fullscreen&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;Here you can see the main game play for this game, as the laser cannon moves back and forth and shoots the falling aliens. The game also displays the elapsed time and the number of aliens shot down on the screen.&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this project, you’ll start by creating the screen that will contain the game. In each step, you’ll create game components such as the laser cannon, lasers, and aliens, and you’ll add the features required to make a functioning game.&lt;/p&gt;
&lt;p&gt;To create this &lt;code&gt;turtle&lt;/code&gt; game, you’ll work through the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create the game &lt;strong&gt;screen&lt;/strong&gt; and the &lt;strong&gt;laser cannon&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Move the cannon&lt;/strong&gt; left and right using keys&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shoot lasers&lt;/strong&gt; with the spacebar&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create aliens&lt;/strong&gt; and move them towards the bottom of the screen&lt;/li&gt;
&lt;li&gt;Determine when &lt;strong&gt;a laser hits an alien&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;End the game&lt;/strong&gt; when an alien reaches the bottom&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;timer&lt;/strong&gt; and a &lt;strong&gt;score&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Improve the cannon’s movement&lt;/strong&gt; to make the game smoother&lt;/li&gt;
&lt;li&gt;Set the game’s &lt;strong&gt;frame rate&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You’ll start with a blank screen, and then see the game come to life one feature at a time as you work through each step in this tutorial.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To complete this tutorial, you should be comfortable with the following concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Repeating code using &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;while&lt;/code&gt; loops&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Using &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;&lt;code&gt;if&lt;/code&gt; statements&lt;/a&gt; to control what happens in different conditions&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;Defining functions&lt;/a&gt; to encapsulate code&lt;/li&gt;
&lt;li&gt;Using &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;lists&lt;/a&gt; to store multiple items&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You don’t need to be familiar with Python’s &lt;code&gt;turtle&lt;/code&gt; to start this tutorial. However, you can &lt;a href=&quot;https://realpython.com/beginners-guide-python-turtle/&quot;&gt;read an overview of the &lt;code&gt;turtle&lt;/code&gt; module&lt;/a&gt; to find out more about the basics.&lt;/p&gt;
&lt;p&gt;If you don’t have all of the prerequisite knowledge before you start, that’s okay! In fact, you might learn more by going ahead and getting started! You can always stop and review the resources linked here if you get stuck.&lt;/p&gt;
&lt;h2 id=&quot;step-1-set-up-the-turtle-game-with-a-screen-and-a-laser-cannon&quot;&gt;Step 1: Set Up the Turtle Game With a Screen and a Laser Cannon&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-set-up-the-turtle-game-with-a-screen-and-a-laser-cannon&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can’t have a game without a screen where all the action happens. So, the first step is to create a blank screen. Then, you can add sprites to represent the items in the game. In this project, you can run your code at any point to see the game in its current state.&lt;/p&gt;
&lt;p&gt;You can download the code as it’ll look at the end of this step from the folder named &lt;code&gt;source_code_step_1/&lt;/code&gt; in the link below:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/build-python-turtle-game-space-invaders-clone/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/build-python-turtle-game-space-invaders-clone/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>SQLite and SQLAlchemy in Python: Move Your Data Beyond Flat Files</title>
      <id>https://realpython.com/courses/sqlite-sqlalchemy-python-beyond-flat-files/</id>
      <link href="https://realpython.com/courses/sqlite-sqlalchemy-python-beyond-flat-files/"/>
      <updated>2024-03-19T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to store and retrieve data using Python, SQLite, and SQLAlchemy as well as with flat files. Using SQLite with Python brings with it the additional benefit of accessing data with SQL. By adding SQLAlchemy, you can work with data in terms of objects and methods.</summary>
      <content type="html">
        &lt;p&gt;All programs process data in one form or another, and many need to be able to save and retrieve that data from one invocation to the next. Python, &lt;a href=&quot;https://www.sqlite.org/index.html&quot;&gt;SQLite&lt;/a&gt;, and &lt;a href=&quot;https://www.sqlalchemy.org/&quot;&gt;SQLAlchemy&lt;/a&gt; give your programs database functionality, allowing you to store data in a single file without the need for a database server.&lt;/p&gt;
&lt;p&gt;You can achieve similar results using &lt;a href=&quot;https://en.wikipedia.org/wiki/Flat-file_database&quot;&gt;flat files&lt;/a&gt; in any number of formats, including CSV, JSON, XML, and even custom formats. Flat files are often human-readable text files&amp;mdash;though they can also be binary data&amp;mdash;with a structure that can be parsed by a computer program. You&amp;rsquo;ll explore using SQL databases and flat files for data storage and manipulation and learn how to decide which approach is right for your program.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to use:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Flat files&lt;/strong&gt; for data storage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQL&lt;/strong&gt; to improve access to persistent data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQLite&lt;/strong&gt; for data storage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQLAlchemy&lt;/strong&gt; to work with data as Python objects&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Model-View-Controller (MVC) in Python Web Apps: Explained With Lego</title>
      <id>https://realpython.com/lego-model-view-controller-python/</id>
      <link href="https://realpython.com/lego-model-view-controller-python/"/>
      <updated>2024-03-18T14:00:00+00:00</updated>
      <summary>This tutorial conceptually explains the Model-View-Controller (MVC) pattern in Python web apps using Lego bricks. Finally understand this important architecture to streamline your web development process.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’re curious about web development, then you’ve likely encountered the abbreviation &lt;strong&gt;MVC&lt;/strong&gt;, which stands for &lt;a href=&quot;http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller&quot;&gt;Model-View-Controller&lt;/a&gt;. You may know that it’s a common design pattern that’s fundamental to many Python web frameworks and even desktop applications.&lt;/p&gt;
&lt;p&gt;But what exactly does it mean? If you’ve had a hard time wrapping your head around the concept, then keep on reading.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Approach &lt;strong&gt;understanding the MVC pattern&lt;/strong&gt; through a &lt;strong&gt;Lego&lt;/strong&gt;-based analogy&lt;/li&gt;
&lt;li&gt;Learn what models, views, and controllers are &lt;strong&gt;conceptually&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Tie your conceptual understanding back to &lt;strong&gt;concrete web development examples&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Investigate &lt;strong&gt;Flask code snippets&lt;/strong&gt; to drive the point home &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Maybe you built things with Lego as a kid, or maybe you’re still a Lego-aficionado today. But even if you’ve never pieced two Lego blocks together, keep on reading because the analogy might still be a good building block for your understanding.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/the-model-view-controller-mvc-paradigm-summarized-with-lego-update-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-the-model-view-controller-mvc-paradigm-summarized-with-lego-update-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download an example Flask app &lt;/a&gt; that will help you understand MVC in Python web apps.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
  &lt;p&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt; Test your knowledge with our interactive “Model-View-Controller (MVC) in Python Web Apps: Explained With Lego” quiz. Upon completion you will receive a score so you can track your learning progress over time:&lt;/p&gt;
  &lt;p class=&quot;text-center my-2&quot;&gt;&lt;a class=&quot;btn btn-primary&quot; href=&quot;/quizzes/model-view-controller-mvc-python-web-apps-lego/&quot; target=&quot;_blank&quot;&gt;Take the Quiz »&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;explaining-the-model-view-controller-pattern-with-lego&quot;&gt;Explaining the Model-View-Controller Pattern With Lego&lt;a class=&quot;headerlink&quot; href=&quot;#explaining-the-model-view-controller-pattern-with-lego&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine that you’re ten years old and sitting on your family room floor. In front of you is a big bucket of &lt;a href=&quot;https://en.wikipedia.org/wiki/Lego&quot;&gt;Lego&lt;/a&gt;, or similar &lt;a href=&quot;https://en.wikipedia.org/wiki/Building_blocks_(toy)&quot;&gt;modular building blocks&lt;/a&gt;. There are blocks of all different shapes and sizes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🟦🟦🟦 Some are blue, tall, and long.&lt;/li&gt;
&lt;li&gt;🟥 Some are red and cube-shaped.&lt;/li&gt;
&lt;li&gt;🟨🟨 Some are yellow, big, and wide.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With all of these different Lego pieces, there’s no telling what you could build!&lt;/p&gt;
&lt;p&gt;Just as your mind is filling with the endless possibilities, you hear something coming from the direction of the couch. It’s your older brother, voicing a specific &lt;strong&gt;request&lt;/strong&gt;. He’s saying, &lt;em&gt;“Hey! Build me a spaceship!”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;“Alright,”&lt;/em&gt; you think, &lt;em&gt;“that could actually be pretty cool.”&lt;/em&gt; A spaceship it is!&lt;/p&gt;
&lt;p&gt;So you get to work. You start pulling out the Lego blocks that you think you’re going to need. Some big, some small. Different colors for the outside of the spaceship, different colors for the engines.&lt;/p&gt;
&lt;p&gt;Now that you have all of your &lt;strong&gt;building blocks&lt;/strong&gt; in place, it’s time to assemble the spaceship. And after a few hours of hard work, you now have in front of you—a spaceship:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;                                  🟦
                                🟦🟥🟦
                              🟦🟥🟥🟥🟦
                            🟦🟥🟥🟥🟥🟥🟦
                            🟦🟥🟥🟥🟥🟥🟦
                            🟦🟥🟩🟩🟩🟥🟦
                            🟦🟥🟩🟦🟩🟥🟦
                            🟦🟥🟩🟩🟩🟥🟦
                            🟦🟥🟥🟥🟥🟥🟦
                            🟦🟥🟥🟥🟥🟥🟦
                            🟦🟥🟥🟥🟥🟥🟦
                        🟦🟥🟥🟥🟥🟥🟥🟥🟥🟥🟦
                        🟦🟥🟥🟥🟥🟥🟥🟥🟥🟥🟦
                        🟦🟥🟨🟨🟥🟥🟥🟨🟨🟥🟦
                            🟨🟨       🟨🟨
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You run to find your brother and show him the finished product. &lt;em&gt;“Wow, nice work!”&lt;/em&gt;, he says. Then he quietly adds:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Huh, I just asked for that a few hours ago, I didn’t have to do a thing, and here it is. I wish &lt;em&gt;everything&lt;/em&gt; was that easy.&lt;/p&gt;
&lt;p&gt;— &lt;em&gt;Your Brother&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;What if I told you that building a web application using the MVC pattern is exactly like building something with Lego blocks?&lt;/p&gt;
&lt;h3 id=&quot;user-sends-a-request&quot;&gt;User Sends a Request&lt;a class=&quot;headerlink&quot; href=&quot;#user-sends-a-request&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/lego-model-view-controller-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/lego-model-view-controller-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #196: Exploring Duck Typing in Python &amp; Dynamics of Monkey Patching</title>
      <id>https://realpython.com/podcasts/rpp/196/</id>
      <link href="https://realpython.com/podcasts/rpp/196/"/>
      <updated>2024-03-15T12:00:00+00:00</updated>
      <summary>What are the advantages of determining the type of an object by how it behaves? What coding circumstances are not a good fit for duck typing? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What are the advantages of determining the type of an object by how it behaves? What coding circumstances are not a good fit for duck typing? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Visualizing Data in Python With Seaborn</title>
      <id>https://realpython.com/python-seaborn/</id>
      <link href="https://realpython.com/python-seaborn/"/>
      <updated>2024-03-13T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use the Python seaborn library to produce statistical data analysis plots to allow you to better visualize your data. You&#x27;ll learn how to use both its traditional classic interface and more modern objects interface.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you have some experience using Python for &lt;a href=&quot;https://realpython.com/python-for-data-analysis/&quot;&gt;data analysis&lt;/a&gt;, chances are you’ve produced some data plots to explain your analysis to other people. Most likely you’ll have used a library such as &lt;a href=&quot;https://realpython.com/python-matplotlib-guide/&quot;&gt;Matplotlib&lt;/a&gt; to produce these. If you want to take your statistical visualizations to the next level, you should master the &lt;a href=&quot;https://seaborn.pydata.org/&quot;&gt;Python seaborn library&lt;/a&gt; to produce impressive statistical analysis plots that will display your data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make an informed judgment as to whether or not seaborn &lt;strong&gt;meets your data visualization needs&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Understand the principles of seaborn’s &lt;strong&gt;classic Python functional interface&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Understand the principles of seaborn’s more &lt;strong&gt;contemporary Python objects interface&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create Python plots using seaborn’s &lt;strong&gt;functions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create Python plots using seaborn’s &lt;strong&gt;objects&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before you start, you should familiarize yourself with the &lt;a href=&quot;https://realpython.com/jupyter-notebook-introduction/&quot;&gt;Jupyter Notebook&lt;/a&gt; data analysis tool available in &lt;a href=&quot;https://realpython.com/using-jupyterlab/&quot;&gt;JupyterLab&lt;/a&gt;. Although you can follow along with this seaborn tutorial using your favorite Python environment, Jupyter Notebook is preferred. You might also like to learn how a &lt;a href=&quot;https://realpython.com/pandas-dataframe/#introducing-the-pandas-dataframe&quot;&gt;pandas DataFrame&lt;/a&gt; stores its data. Knowing the difference between a pandas &lt;a href=&quot;https://pandas.pydata.org/docs/user_guide/dsintro.html#dataframe&quot;&gt;DataFrame&lt;/a&gt; and &lt;a href=&quot;https://pandas.pydata.org/docs/user_guide/dsintro.html#series&quot;&gt;Series&lt;/a&gt; will also prove useful.&lt;/p&gt;
&lt;p&gt;So now it’s time for you to dive right in and learn how to use seaborn to produce your Python plots.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-seaborn-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-seaborn-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free code&lt;/a&gt; that you can experiment with in Python seaborn.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-started-with-python-seaborn&quot;&gt;Getting Started With Python seaborn&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-python-seaborn&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you use seaborn, you must install it. Open a Jupyter Notebook and type &lt;code&gt;!python -m pip install seaborn&lt;/code&gt; into a new code cell. When you run the cell, seaborn will install. If you’re working at the command line, use the same command, only without the exclamation point (&lt;code&gt;!&lt;/code&gt;). Once seaborn is installed, &lt;a href=&quot;https://realpython.com/python-matplotlib-guide/&quot;&gt;Matplotlib&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; will also be available. This is handy because sometimes you need them to enhance your Python seaborn plots.&lt;/p&gt;
&lt;p&gt;Before you can create a plot, you do, of course, need data. Later, you’ll create several plots using different publicly available datasets containing real-world data. To begin with, you’ll work with some &lt;a href=&quot;https://github.com/mwaskom/seaborn-data&quot;&gt;sample data&lt;/a&gt; provided for you by the creators of seaborn. More specifically, you’ll work with their &lt;code&gt;tips&lt;/code&gt; dataset. This dataset contains data about each tip that a particular restaurant waiter received over a few months.&lt;/p&gt;
&lt;h3 id=&quot;creating-a-bar-plot-with-seaborn&quot;&gt;Creating a Bar Plot With seaborn&lt;a class=&quot;headerlink&quot; href=&quot;#creating-a-bar-plot-with-seaborn&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Suppose you wanted to see a &lt;a href=&quot;https://en.wikipedia.org/wiki/Bar_chart&quot;&gt;bar plot&lt;/a&gt; showing the average amount of tips received by the waiter each day. You could write some Python seaborn code to do this:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;ipython&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;In [1]: &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;seaborn&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sns&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;   ...:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tips&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load_dataset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tips&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;   ...:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;barplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tips&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tip&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;estimator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mean&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;errorbar&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Daily Tips ($)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;   ...:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;   ...: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;First, you import seaborn into your Python code. By convention, you import it as &lt;code&gt;sns&lt;/code&gt;. Although you can use any alias you like, &lt;code&gt;sns&lt;/code&gt; is a nod to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Sam_Seaborn&quot;&gt;fictional character&lt;/a&gt; the library was named after.&lt;/p&gt;
&lt;p&gt;To work with data in seaborn, you usually load it into a pandas DataFrame, although &lt;a href=&quot;https://seaborn.pydata.org/tutorial/data_structure.html#data-structures-accepted-by-seaborn&quot;&gt;other data structures&lt;/a&gt; can also be used. The usual way of loading data is to use the pandas &lt;code&gt;read_csv()&lt;/code&gt; function to read data from a file on disk. You’ll see how to do this later.&lt;/p&gt;
&lt;p&gt;To begin with, because you’re working with one of the seaborn sample datasets, seaborn allows you online access to these using its &lt;code&gt;load_dataset()&lt;/code&gt; function. You can see a list of the freely available files on their &lt;a href=&quot;https://github.com/mwaskom/seaborn-data&quot;&gt;GitHub repository&lt;/a&gt;. To obtain the one you want, all you need to do is pass &lt;code&gt;load_dataset()&lt;/code&gt; a string telling it the name of the file containing the dataset you’re interested in, and it’ll be loaded into a pandas DataFrame for you to use.&lt;/p&gt;
&lt;p&gt;The actual bar plot is created using seaborn’s &lt;a href=&quot;https://seaborn.pydata.org/generated/seaborn.barplot.html#seaborn.barplot&quot;&gt;&lt;code&gt;barplot()&lt;/code&gt;&lt;/a&gt; function. You’ll learn more about the different plotting functions later, but for now, you’ve specified &lt;code&gt;data=tips&lt;/code&gt; as the DataFrame you wish to use and also told the function to plot the &lt;code&gt;day&lt;/code&gt; and &lt;code&gt;tip&lt;/code&gt; columns from it. These contain the day the tip was received and the tip amount, respectively.&lt;/p&gt;
&lt;p&gt;The important point you should notice here is that the seaborn &lt;code&gt;barplot()&lt;/code&gt; function, like all seaborn plotting functions, can understand pandas DataFrames instinctively. To specify a column of data for them to use, you pass its column name as a string. There’s no need to write pandas code to identify each Series to be plotted.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;estimator=&quot;mean&quot;&lt;/code&gt; parameter tells seaborn to plot the mean &lt;code&gt;y&lt;/code&gt; values for each category of &lt;code&gt;x&lt;/code&gt;.  This means your plot will show the average tip for each day. You can quickly customize this to instead use common statistical functions such as &lt;code&gt;sum&lt;/code&gt;, &lt;code&gt;max&lt;/code&gt;, &lt;code&gt;min&lt;/code&gt;, and &lt;code&gt;median&lt;/code&gt;, but &lt;code&gt;estimator=&quot;mean&quot;&lt;/code&gt; is the default. The plot will also show &lt;a href=&quot;https://en.wikipedia.org/wiki/Error_bar&quot;&gt;error bars&lt;/a&gt; by default. By setting &lt;code&gt;errorbar=None&lt;/code&gt;, you can suppress them.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;barplot()&lt;/code&gt; function will produce a plot using the parameters you pass to it, and it’ll label each axis using the column name of the data that you want to see. Once &lt;code&gt;barplot()&lt;/code&gt; is finished, it returns a matplotlib &lt;a href=&quot;https://matplotlib.org/stable/api/axes_api.html&quot;&gt;&lt;code&gt;Axes&lt;/code&gt;&lt;/a&gt; object containing the plot. To give the plot a title, you need to call the &lt;code&gt;Axes&lt;/code&gt; object’s &lt;code&gt;.set()&lt;/code&gt; method and pass it the title you want. Notice that this was all done from within seaborn directly, and not Matplotlib.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You may be wondering why the &lt;code&gt;barplot()&lt;/code&gt; function is encapsulated within a pair of parentheses &lt;code&gt;(...)&lt;/code&gt;. This is a coding style often used in seaborn code because it frequently uses &lt;a href=&quot;https://en.wikipedia.org/wiki/Method_chaining&quot;&gt;method chaining&lt;/a&gt;. These extra brackets allow you to horizontally align method calls, starting each with its dot notation. Alternatively, you could use the backslash (&lt;code&gt;\&lt;/code&gt;) for line continuation, although that is &lt;a href=&quot;https://peps.python.org/pep-0008/#maximum-line-length&quot;&gt;discouraged&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you take another look at the code, the alignment of &lt;code&gt;.set()&lt;/code&gt; is only possible because of these extra encasing brackets. You’ll see this coding style used throughout this tutorial, as well as when you read the &lt;a href=&quot;https://seaborn.pydata.org/#&quot;&gt;seaborn documentation&lt;/a&gt;.  &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In some environments like &lt;a href=&quot;https://realpython.com/ipython-interactive-python-shell/&quot;&gt;IPython&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/pycharm-guide/&quot;&gt;PyCharm&lt;/a&gt;, you may need to use Matplotlib’s &lt;code&gt;show()&lt;/code&gt; function to display your plot, meaning you must import Matplotlib into Python as well. If you’re using a Jupyter notebook, then using &lt;code&gt;plt.show()&lt;/code&gt; isn’t necessary, but using it removes some unwanted text above your plot. Placing a semicolon (&lt;code&gt;;&lt;/code&gt;) at the end of &lt;code&gt;barplot()&lt;/code&gt; will also do this for you.  &lt;/p&gt;
&lt;p&gt;When you run the code, the resulting plot will look like this:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/ie_daily_tips.53d0cdb6eb5d.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block &quot; src=&quot;https://files.realpython.com/media/ie_daily_tips.53d0cdb6eb5d.png&quot; width=&quot;708&quot; height=&quot;561&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/ie_daily_tips.53d0cdb6eb5d.png&amp;amp;w=177&amp;amp;sig=094644e84ae714d81f254e60710ffedb71c2f983 177w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/ie_daily_tips.53d0cdb6eb5d.png&amp;amp;w=236&amp;amp;sig=41e9f8b944ab94f48624cfedc7b9393cd7d38fe9 236w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/ie_daily_tips.53d0cdb6eb5d.png&amp;amp;w=354&amp;amp;sig=9540e2d9af8c4189fd13cc3e6f073b427ccf910b 354w, https://files.realpython.com/media/ie_daily_tips.53d0cdb6eb5d.png 708w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Barplot showing a waiter&#x27;s daily tips.&quot; data-asset=&quot;5658&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;As you can see, the waiter’s daily average tips rise slightly on the weekends. It looks as though people tip more when they’re relaxed.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; One thing you should be aware of is that &lt;code&gt;load_dataset()&lt;/code&gt;, unlike &lt;code&gt;read_csv()&lt;/code&gt;, will automatically convert string columns into the pandas &lt;a href=&quot;https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html&quot;&gt;&lt;code&gt;Categorical&lt;/code&gt;&lt;/a&gt; data type for you. You use this where your data contains a limited, fixed number of possible values. In this case, the &lt;code&gt;day&lt;/code&gt; column of data will be treated as a &lt;code&gt;Categorical&lt;/code&gt; data type containing the days of the week. You can see this by using &lt;code&gt;tips[&quot;day&quot;]&lt;/code&gt; to view the column:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;ipython&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;In [2]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tips&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;gh&quot;&gt;Out[2]:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0       Sun&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1       Sun&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2       Sun&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3       Sun&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;4       Sun&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;       ...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;239     Sat&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;240     Sat&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;241     Sat&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;242     Sat&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;243    Thur&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;Name: day, Length: 244, dtype: category&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;Categories (4, object): [&#x27;Thur&#x27;, &#x27;Fri&#x27;, &#x27;Sat&#x27;, &#x27;Sun&#x27;]&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, your &lt;code&gt;day&lt;/code&gt; column has a data type of &lt;code&gt;category&lt;/code&gt;. Note, also, that while your original data starts with &lt;code&gt;Sun&lt;/code&gt;, the first entry in the &lt;code&gt;category&lt;/code&gt; is &lt;code&gt;Thur&lt;/code&gt;. In creating the category, the days have been interpreted for you in the correct order. The &lt;code&gt;read_csv()&lt;/code&gt; function doesn’t do this.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-seaborn/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-seaborn/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics Exercises: Dictionaries</title>
      <id>https://realpython.com/courses/basics-exercises-dictionaries/</id>
      <link href="https://realpython.com/courses/basics-exercises-dictionaries/"/>
      <updated>2024-03-12T14:00:00+00:00</updated>
      <summary>One of the most useful data structures in Python is the dictionary. In this video course, you’ll practice working with Python dictionaries, see how dictionaries differ from lists and tuples, and define and use dictionaries in your own code.</summary>
      <content type="html">
        &lt;p&gt;In plain English, a dictionary is a book containing the definitions of words. Each entry in a dictionary has two parts: the word being defined, and its definition.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Python dictionaries&lt;/strong&gt;, like lists and tuples, store a collection of objects. However, instead of storing objects in a sequence, dictionaries hold
information in pairs of data called &lt;strong&gt;key-value pairs&lt;/strong&gt;. That is, each object in a dictionary has two parts: a &lt;strong&gt;key&lt;/strong&gt; and a &lt;strong&gt;value&lt;/strong&gt;. Each key is assigned a single value, which defines the relationship between the two sets.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll practice:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What a dictionary &lt;strong&gt;is&lt;/strong&gt; and how it&amp;rsquo;s &lt;strong&gt;structured&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How dictionaries &lt;strong&gt;differ&lt;/strong&gt; from other data structures&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;define&lt;/strong&gt; and &lt;strong&gt;use&lt;/strong&gt; dictionaries in your own code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. You can also check out the other &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics courses&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python News: What&#x27;s New From February 2024</title>
      <id>https://realpython.com/python-news-february-2024/</id>
      <link href="https://realpython.com/python-news-february-2024/"/>
      <updated>2024-03-11T14:00:00+00:00</updated>
      <summary>February 2024 sees Python security updates and the introduction of a Rust-based tool for packaging, while the Python community gears up for PyCon US and the PSF enhances support with Grants Program Office Hours.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;As February takes a &lt;a href=&quot;https://en.wikipedia.org/wiki/Leap_year&quot;&gt;rare leap&lt;/a&gt; forward with an extra day this year, the Python community followed suit!&lt;/p&gt;
&lt;p&gt;Python versions 3.12 and 3.11 receive a &lt;strong&gt;security fix&lt;/strong&gt;, and CPython source distributions now document the &lt;strong&gt;software supply chain&lt;/strong&gt; to allow for a more effective vulnerability detection. Another Rust-based tool makes its way into the Python ecosystem, promising exciting improvements to the existing &lt;strong&gt;package management&lt;/strong&gt; system.&lt;/p&gt;
&lt;p&gt;Looking ahead, the reveal of the &lt;strong&gt;PyCon US 2024&lt;/strong&gt; schedule gives us a glimpse into the upcoming Python conference. In other news, the Python Software Foundation launches recurring &lt;strong&gt;Office Hours&lt;/strong&gt; to enhance community support in the Grants Program.&lt;/p&gt;
&lt;p&gt;Let’s dive into the biggest &lt;strong&gt;Python news&lt;/strong&gt; from the past month!&lt;/p&gt;
&lt;h2 id=&quot;python-312-and-311-receive-a-security-fix&quot;&gt;Python 3.12 and 3.11 Receive a Security Fix&lt;a class=&quot;headerlink&quot; href=&quot;#python-312-and-311-receive-a-security-fix&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.python.org/downloads/release/python-3122/&quot;&gt;Python 3.12.2&lt;/a&gt; and &lt;a href=&quot;https://www.python.org/downloads/release/python-3118/&quot;&gt;Python 3.11.8&lt;/a&gt; patch versions were released, incorporating hundreds of commits and a host of bug fixes. Aside from that, they both provide a &lt;a href=&quot;https://docs.python.org/release/3.12.2/whatsnew/changelog.html#security&quot;&gt;small security fix&lt;/a&gt; to an obscure feature of Python that allows for arbitrary code execution.&lt;/p&gt;
&lt;p&gt;In a nutshell, this new security fix forbids the processing of hidden &lt;strong&gt;path configuration files&lt;/strong&gt; (&lt;code&gt;.pth&lt;/code&gt;) located in a virtual environment’s &lt;code&gt;site-packages/&lt;/code&gt; folder:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;venv/
│
├── bin/
│
├── include/
│
├── lib/
│   │
│   └── python3.12/
│       │
│       └── site-packages/
│           │
&lt;span class=&quot;hll&quot;&gt;│           └── .your-hidden.pth
&lt;/span&gt;│
├── lib64/
│
└── pyvenv.cfg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On a Unix-like operating system, any file becomes implicitly hidden when its name starts with a leading dot. On Windows, a file needs the corresponding attribute set to be hidden. Note that the directory structure presented above might look slightly different on Windows.&lt;/p&gt;
&lt;p&gt;Path configuration files are plain text files that the &lt;a href=&quot;https://docs.python.org/3/library/site.html#module-site&quot;&gt;&lt;code&gt;site&lt;/code&gt;&lt;/a&gt; module in the Python standard library automatically parses and processes upon the interpreter startup. Historically, these files helped facilitate &lt;a href=&quot;https://setuptools.pypa.io/en/latest/userguide/development_mode.html&quot;&gt;editable installs&lt;/a&gt; and implement hooks into the &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;importing machinery&lt;/a&gt;. They essentially let you append extra folders to the &lt;strong&gt;Python search path&lt;/strong&gt;, which is accessible through the  &lt;code&gt;sys.path&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;Unfortunately, &lt;code&gt;.pth&lt;/code&gt; files have a quirk that makes it possible to execute any code on startup:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;text&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--grey&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Text&lt;/span&gt;
    &lt;span class=&quot;mr-2&quot; aria-label=&quot;Filename&quot;&gt;&lt;code style=&quot;color: inherit;&quot;&gt;venv/lib/python3.12/site-packages/.your-hidden.pth&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;import os; print(&quot;This will run on Python startup!&quot;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-february-2024/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-february-2024/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #195: Building a Healthy Developer Mindset While Learning Python</title>
      <id>https://realpython.com/podcasts/rpp/195/</id>
      <link href="https://realpython.com/podcasts/rpp/195/"/>
      <updated>2024-03-08T12:00:00+00:00</updated>
      <summary>How do you get yourself unstuck when facing a programming problem? How do you develop a positive developer mindset while learning Python? This week on the show, Bob Belderbos from Pybites is here to talk about learning Python and building healthy developer habits.</summary>
      <content type="html">
        &lt;p&gt;How do you get yourself unstuck when facing a programming problem? How do you develop a positive developer mindset while learning Python? This week on the show, Bob Belderbos from Pybites is here to talk about learning Python and building healthy developer habits.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Build an LLM RAG Chatbot With LangChain</title>
      <id>https://realpython.com/build-llm-rag-chatbot-with-langchain/</id>
      <link href="https://realpython.com/build-llm-rag-chatbot-with-langchain/"/>
      <updated>2024-03-06T14:00:00+00:00</updated>
      <summary>Large language models (LLMs) have taken the world by storm, demonstrating unprecedented capabilities in natural language tasks. In this step-by-step tutorial, you&#x27;ll leverage LLMs to build your own retrieval-augmented generation (RAG) chatbot using synthetic data with LangChain and Neo4j.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You’ve likely interacted with large language models (LLMs), like the ones behind OpenAI’s ChatGPT, and experienced their remarkable ability to answer questions, summarize documents, write code, and much more. While LLMs are remarkable by themselves, with a little programming knowledge, you can leverage libraries like &lt;a href=&quot;https://python.langchain.com/docs/get_started/introduction&quot;&gt;LangChain&lt;/a&gt; to create your own LLM-powered chatbots that can do just about anything.&lt;/p&gt;
&lt;p&gt;In an enterprise setting, one of the most popular ways to create an LLM-powered chatbot is through retrieval-augmented generation (RAG). When you design a RAG system, you use a retrieval model to retrieve relevant information, usually from a database or corpus, and provide this retrieved information to an LLM to generate contextually relevant responses.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll step into the shoes of an AI engineer working for a large hospital system. You’ll build a RAG chatbot in LangChain that uses &lt;a href=&quot;https://neo4j.com/&quot;&gt;Neo4j&lt;/a&gt; to retrieve data about the patients, patient experiences, hospital locations, visits, insurance payers, and physicians in your hospital system.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;LangChain&lt;/strong&gt; to build custom &lt;strong&gt;chatbots&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Design&lt;/strong&gt; a chatbot using your understanding of the business requirements and hospital system data&lt;/li&gt;
&lt;li&gt;Work with &lt;strong&gt;graph databases&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Set up a &lt;strong&gt;Neo4j&lt;/strong&gt; AuraDB instance&lt;/li&gt;
&lt;li&gt;Build a &lt;strong&gt;RAG&lt;/strong&gt; chatbot that retrieves both &lt;strong&gt;structured&lt;/strong&gt; and &lt;strong&gt;unstructured&lt;/strong&gt; data from Neo4j&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deploy&lt;/strong&gt; your chatbot with &lt;strong&gt;FastAPI&lt;/strong&gt; and &lt;strong&gt;Streamlit&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click the link below to download the complete source code and data for this project:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-llm-rag-chatbot-with-langchain-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-llm-rag-chatbot-with-langchain-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; for your LangChain chatbot.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;demo-an-llm-rag-chatbot-with-langchain-and-neo4j&quot;&gt;Demo: An LLM RAG Chatbot With LangChain and Neo4j&lt;a class=&quot;headerlink&quot; href=&quot;#demo-an-llm-rag-chatbot-with-langchain-and-neo4j&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;By the end of this tutorial, you’ll have a &lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;REST API&lt;/a&gt; that serves your LangChain chatbot. You’ll also have a &lt;a href=&quot;https://streamlit.io/&quot;&gt;Streamlit&lt;/a&gt; app that provides a nice chat interface to interact with your API:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/918999422&quot; frameborder=&quot;0&quot; allow=&quot;fullscreen&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;Under the hood, the Streamlit app sends your messages to the chatbot API, and the chatbot generates and sends a response back to the Streamlit app, which displays it to the user. &lt;/p&gt;
&lt;p&gt;You’ll get an in-depth overview of the data that your chatbot has access to later, but if you’re anxious to test it out, you can ask questions similar to the examples given in the sidebar:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/Screenshot_2024-01-01_at_2.34.47_PM.fa9ed6c58d87.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block &quot; src=&quot;https://files.realpython.com/media/Screenshot_2024-01-01_at_2.34.47_PM.fa9ed6c58d87.png&quot; width=&quot;2686&quot; height=&quot;1710&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/Screenshot_2024-01-01_at_2.34.47_PM.fa9ed6c58d87.png&amp;amp;w=671&amp;amp;sig=8dca32f0154574458d7f1f06fa043e70cc5c9b6f 671w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/Screenshot_2024-01-01_at_2.34.47_PM.fa9ed6c58d87.png&amp;amp;w=895&amp;amp;sig=419dc6ad2cda94fac29893c6ebffa9bc879f9150 895w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/Screenshot_2024-01-01_at_2.34.47_PM.fa9ed6c58d87.png&amp;amp;w=1343&amp;amp;sig=91d92233da6b80475093666845efb6a5e32e8885 1343w, https://files.realpython.com/media/Screenshot_2024-01-01_at_2.34.47_PM.fa9ed6c58d87.png 2686w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Example questions that the chatbot can answer&quot; data-asset=&quot;5619&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Example questions can be found in the sidebar.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;You’ll learn how to tackle each step, from understanding the business requirements and data to building the Streamlit app. There’s a lot to unpack in this tutorial, but don’t feel overwhelmed. You’ll get some background on each concept introduced, along with links to external sources that will deepen your understanding. Now, it’s time to dive in!&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This tutorial is best suited for intermediate Python developers who want to get hands-on experience creating custom chatbots. Aside from intermediate Python knowledge, you’ll benefit from having a high-level understanding of the following concepts and technologies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Large language models (LLMs) and &lt;a href=&quot;https://realpython.com/practical-prompt-engineering/&quot;&gt;prompt engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/chromadb-vector-database/#represent-data-as-vectors&quot;&gt;Text embeddings and vector databases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://neo4j.com/developer/graph-database/&quot;&gt;Graph databases&lt;/a&gt; and &lt;a href=&quot;https://neo4j.com/docs/getting-started/languages-guides/neo4j-python/&quot;&gt;Neo4j&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://openai.com/product&quot;&gt;The OpenAI developer ecosystem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;REST APIs&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/fastapi-python-web-apis/&quot;&gt;FastAPI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/async-io-python/&quot;&gt;Asynchronous programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/tutorials/docker/&quot;&gt;Docker&lt;/a&gt; and &lt;a href=&quot;https://docs.docker.com/compose/&quot;&gt;Docker Compose&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nothing listed above is a hard prerequisite, so don’t worry if you don’t feel knowledgeable in any of them. You’ll be introduced to each concept and technology along the way. Besides, there’s no better way to learn these prerequisites than to implement them yourself in this tutorial. &lt;/p&gt;
&lt;p&gt;Next up, you’ll get a brief project overview and begin learning about LangChain.&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Throughout this tutorial, you’ll create a few directories that make up your final chatbot. Here’s a breakdown of each directory:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;langchain_intro/&lt;/code&gt; will help you get familiar with LangChain and equip you with the tools that you need to build the chatbot you saw in the demo, and it won’t be included in your final chatbot. You’ll cover this in &lt;a href=&quot;#step-1-get-familiar-with-langchain&quot;&gt;Step 1&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;data/&lt;/code&gt; has the raw hospital system data stored as CSV files. You’ll explore this data in &lt;a href=&quot;#step-2-understand-the-business-requirements-and-data&quot;&gt;Step 2&lt;/a&gt;. In &lt;a href=&quot;#step-3-set-up-a-neo4j-graph-database&quot;&gt;Step 3&lt;/a&gt;, you’ll move this data into a Neo4j database that your chatbot will query to answer questions. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;hospital_neo4j_etl/&lt;/code&gt; contains a script that loads the raw data from &lt;code&gt;data/&lt;/code&gt; into your Neo4j database. You have to run this before building your chatbot, and you’ll learn everything you need to know about setting up a Neo4j instance in &lt;a href=&quot;#step-3-set-up-a-neo4j-graph-database&quot;&gt;Step 3&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;chatbot_api/&lt;/code&gt; is your &lt;a href=&quot;https://realpython.com/fastapi-python-web-apis/&quot;&gt;FastAPI&lt;/a&gt; app that serves your chatbot as a REST endpoint, and it’s the core deliverable of this project. The &lt;code&gt;chatbot_api/src/agents/&lt;/code&gt; and &lt;code&gt;chatbot_api/src/chains/&lt;/code&gt; subdirectories contain the LangChain objects that comprise your chatbot. You’ll learn what agents and chains are later, but for now, just know that your chatbot is actually a LangChain agent composed of chains and functions. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;tests/&lt;/code&gt; includes two scripts that test how fast your chatbot can answer a series of questions. This will give you a feel for how much time you save by making asynchronous requests to LLM providers like OpenAI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;chatbot_frontend/&lt;/code&gt; is your Streamlit app that interacts with the chatbot endpoint in &lt;code&gt;chatbot_api/&lt;/code&gt;. This is the UI that you saw in the demo, and you’ll build this in &lt;a href=&quot;#step-5-deploy-the-langchain-agent&quot;&gt;Step 5&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the environment variables needed to build and run your chatbot will be stored in a &lt;code&gt;.env&lt;/code&gt; file. You’ll deploy the code in &lt;code&gt;hospital_neo4j_etl/&lt;/code&gt;, &lt;code&gt;chatbot_api&lt;/code&gt;, and &lt;code&gt;chatbot_frontend&lt;/code&gt; as Docker containers that’ll be orchestrated with Docker Compose. If you want to experiment with the chatbot before going through the rest of this tutorial, then you can download the materials and follow the instructions in the README file to get things running:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-llm-rag-chatbot-with-langchain-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-llm-rag-chatbot-with-langchain-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; for your LangChain chatbot.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;With the project overview and prerequisites behind you, you’re ready to get started with the first step—getting familiar with LangChain.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/build-llm-rag-chatbot-with-langchain/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/build-llm-rag-chatbot-with-langchain/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Creating Asynchronous Tasks With Celery and Django</title>
      <id>https://realpython.com/courses/asynchronous-tasks-celery-django/</id>
      <link href="https://realpython.com/courses/asynchronous-tasks-celery-django/"/>
      <updated>2024-03-05T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to integrate Celery and Django using Redis as a message broker. You&#x27;ll refactor the synchronous email sending functionality of an existing Django app into an asynchronous task that you&#x27;ll run with Celery instead.</summary>
      <content type="html">
        &lt;p&gt;You&amp;rsquo;ve built a shiny &lt;strong&gt;Django&lt;/strong&gt; app and want to release it to the public, but you&amp;rsquo;re worried about time-intensive tasks that are part of your app&amp;rsquo;s workflow. You don&amp;rsquo;t want your users to have a negative experience navigating your app. You can integrate &lt;strong&gt;Celery&lt;/strong&gt; to help with that.&lt;/p&gt;
&lt;p&gt;Celery is a &lt;strong&gt;distributed task queue&lt;/strong&gt; for UNIX systems. It allows you to offload work from your Python app. Once you integrate Celery into your app, you can send time-intensive tasks to Celery&amp;rsquo;s task queue. That way, your web app can continue to respond quickly to users while Celery completes expensive operations asynchronously in the background.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Recognize &lt;strong&gt;effective use cases&lt;/strong&gt; for Celery&lt;/li&gt;
&lt;li&gt;Differentiate between &lt;strong&gt;Celery beat&lt;/strong&gt; and &lt;strong&gt;Celery workers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integrate Celery and Redis&lt;/strong&gt; in a Django project&lt;/li&gt;
&lt;li&gt;Set up &lt;strong&gt;asynchronous tasks&lt;/strong&gt; that run independently of your Django app&lt;/li&gt;
&lt;li&gt;Refactor Django code to &lt;strong&gt;run a task with Celery&lt;/strong&gt; instead&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s __all__: Packages, Modules, and Wildcard Imports</title>
      <id>https://realpython.com/python-all-attribute/</id>
      <link href="https://realpython.com/python-all-attribute/"/>
      <updated>2024-03-04T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about wildcard imports and the __all__ variable in Python. With __all__, you can prepare your packages and modules for wildcard imports, which are a quick way to import everything.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python has something called &lt;strong&gt;wildcard imports&lt;/strong&gt;, which look like &lt;code&gt;from module import *&lt;/code&gt;. This type of import allows you to quickly get all the objects from a module into your namespace. However, using this import on a package can be confusing because it’s not clear what you want to import: subpackages, modules, objects? Python has the &lt;strong&gt;&lt;code&gt;__all__&lt;/code&gt;&lt;/strong&gt; variable to work around this issue.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;__all__&lt;/code&gt; variable is a list of strings where each string represents the name of a variable, function, class, or module that you want to expose to wildcard imports.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand &lt;strong&gt;wildcard imports&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;__all__&lt;/code&gt;&lt;/strong&gt; to control the modules that you &lt;strong&gt;expose&lt;/strong&gt; to wildcard imports&lt;/li&gt;
&lt;li&gt;Control the &lt;strong&gt;names&lt;/strong&gt; that you expose in &lt;strong&gt;modules&lt;/strong&gt; and &lt;strong&gt;packages&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Explore &lt;strong&gt;other use cases&lt;/strong&gt; of the &lt;code&gt;__all__&lt;/code&gt; variable&lt;/li&gt;
&lt;li&gt;Learn some &lt;strong&gt;benefits&lt;/strong&gt; and &lt;strong&gt;best practices&lt;/strong&gt; of using &lt;code&gt;__all__&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with a few Python concepts, including &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;modules and packages&lt;/a&gt;, and the &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;import&lt;/a&gt; system.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-all-attribute-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-all-attribute-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use Python’s &lt;code&gt;__all__&lt;/code&gt; attribute.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;importing-objects-in-python&quot;&gt;Importing Objects in Python&lt;a class=&quot;headerlink&quot; href=&quot;#importing-objects-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When creating a Python project or application, you’ll need a way to access code from the &lt;a href=&quot;https://docs.python.org/3/library/index.html&quot;&gt;standard library&lt;/a&gt; or third-party libraries. You’ll also need to access your own code from the multiple files that may make up your project. Python’s &lt;a href=&quot;https://docs.python.org/3/reference/import.html#the-import-system&quot;&gt;import system&lt;/a&gt; is the mechanism that allows you to do this.&lt;/p&gt;
&lt;p&gt;The import system lets you get objects in different ways. You can use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Explicit imports&lt;/li&gt;
&lt;li&gt;Wildcard imports&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the following sections, you’ll learn the basics of both strategies. You’ll learn about the different syntax that you can use in each case and the result of running an &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;&lt;code&gt;import&lt;/code&gt;&lt;/a&gt; statement.&lt;/p&gt;
&lt;h3 id=&quot;explicit-imports&quot;&gt;Explicit Imports&lt;a class=&quot;headerlink&quot; href=&quot;#explicit-imports&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Python, when you need to get a specific object from a &lt;a href=&quot;https://realpython.com/python-modules-packages/#python-modules-overview&quot;&gt;module&lt;/a&gt; or a particular module from a &lt;a href=&quot;https://realpython.com/python-modules-packages/#python-packages&quot;&gt;package&lt;/a&gt;, you can use an &lt;strong&gt;explicit &lt;code&gt;import&lt;/code&gt; statement&lt;/strong&gt;. This type of statement allows you to bring the target object to your current &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;namespace&lt;/a&gt; so that you can use the object in your code.&lt;/p&gt;
&lt;p&gt;To import a module by its name, you can use the following syntax:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This statement allows you to import a module by its name. The module must be listed in Python’s &lt;a href=&quot;https://realpython.com/python-import/#pythons-import-path&quot;&gt;import path&lt;/a&gt;, which is a list of locations where the &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-path-based-finder&quot;&gt;path based finder&lt;/a&gt; searches when you run an import.&lt;/p&gt;
&lt;p&gt;The part of the syntax that’s enclosed in square brackets is optional and allows you to create an &lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/#aliasing-variables&quot;&gt;alias&lt;/a&gt; of the imported name. This practice can help you avoid name collisions in your code.&lt;/p&gt;
&lt;p&gt;As an example, say that you have the following module:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    &lt;span class=&quot;mr-2&quot; aria-label=&quot;Filename&quot;&gt;&lt;code style=&quot;color: inherit;&quot;&gt;calculations.py&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;subtract&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;multiply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;divide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This sample module provides functions that allow you to perform basic calculations. The containing module is called &lt;code&gt;calculations.py&lt;/code&gt;. To import this module and use the functions in your code, go ahead and start a &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt; session in the same directory where you saved the file.&lt;/p&gt;
&lt;p&gt;Then run the following code:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;calculations&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calculations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;6.0&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calculations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subtract&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;4.0&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calculations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;multiply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;10.0&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calculations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;divide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;6.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;import&lt;/code&gt; statement at the beginning of this code snippet brings the module name to your current namespace. To use the functions or any other object from &lt;code&gt;calculations&lt;/code&gt;, you need to use fully &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-qualified-name&quot;&gt;qualified names&lt;/a&gt; with the dot notation.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can create an alias of &lt;code&gt;calculations&lt;/code&gt; using the following syntax:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;calculations&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;calc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This practice allows you to avoid name clashes in your code. In some contexts, it’s also common practice to reduce the number of characters to type when using qualified names.&lt;/p&gt;
&lt;p&gt;For example, if you’re familiar with libraries like &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-pandas-tricks/&quot;&gt;pandas&lt;/a&gt;, then you’ll know that it’s common to use the following imports:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using shorter aliases when you import modules facilitates using their content by taking advantage of qualified names.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You can also use a similar syntax to import a Python package:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-all-attribute/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-all-attribute/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #194: Automate Tasks With Python &amp; Building a Small Search Engine</title>
      <id>https://realpython.com/podcasts/rpp/194/</id>
      <link href="https://realpython.com/podcasts/rpp/194/"/>
      <updated>2024-03-01T12:00:00+00:00</updated>
      <summary>What are the typical computer tasks you do manually every week? Could you automate those tasks with a Python script? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What are the typical computer tasks you do manually every week? Could you automate those tasks with a Python script? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s Requests Library (Guide)</title>
      <id>https://realpython.com/python-requests/</id>
      <link href="https://realpython.com/python-requests/"/>
      <updated>2024-02-28T14:00:00+00:00</updated>
      <summary>In this tutorial on Python&#x27;s Requests library, you&#x27;ll see some of the most useful features that Requests has to offer as well as ways to customize and optimize those features. You&#x27;ll learn how to use requests efficiently and stop requests to external services from slowing down your application.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The &lt;a href=&quot;https://requests.readthedocs.io/en/latest/&quot;&gt;Requests&lt;/a&gt; library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application.&lt;/p&gt;
&lt;p&gt;Throughout this tutorial, you’ll see some of the most useful features that Requests has to offer as well as ways to customize and optimize those features for different situations that you may come across. You’ll also learn how to use Requests in an efficient way as well as how to prevent requests to external services from slowing down your application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Make requests&lt;/strong&gt; using the most common HTTP methods&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Customize&lt;/strong&gt; your requests’ headers and data using the query string and message body&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inspect&lt;/strong&gt; data from your requests and responses&lt;/li&gt;
&lt;li&gt;Make &lt;strong&gt;authenticated&lt;/strong&gt; requests&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Configure&lt;/strong&gt; your requests to help prevent your application from backing up or slowing down&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the best experience working through this tutorial, you should have &lt;a href=&quot;https://www.w3schools.com/tags/ref_httpmethods.asp&quot;&gt;basic general knowledge of HTTP&lt;/a&gt;. That said, you still may be able to follow along fine without it.&lt;/p&gt;
&lt;p&gt;In the upcoming sections, you’ll see how you can install and use &lt;code&gt;requests&lt;/code&gt; in your application. If you want to play with the code examples that you’ll see in this tutorial, as well as some additional ones, then you can download the code examples and work with them locally:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-requests-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-requests-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use Python’s Requests library.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
  &lt;p&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt; Test your knowledge with our interactive “HTTP Requests With the &quot;requests&quot; Library” quiz. Upon completion you will receive a score so you can track your learning progress over time:&lt;/p&gt;
  &lt;p class=&quot;text-center my-2&quot;&gt;&lt;a class=&quot;btn btn-primary&quot; href=&quot;/quizzes/python-requests/&quot; target=&quot;_blank&quot;&gt;Take the Quiz »&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;getting-started-with-pythons-requests-library&quot;&gt;Getting Started With Python’s Requests Library&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-pythons-requests-library&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Even though the Requests library is a common staple for many Python developers, it’s not included in &lt;a href=&quot;https://docs.python.org/3/library/index.html&quot;&gt;Python’s standard library&lt;/a&gt;. There are &lt;a href=&quot;https://github.com/psf/requests/issues/2424&quot;&gt;good reasons for that decision&lt;/a&gt;, primarily that the library can continue to evolve more freely as a self-standing project.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Requests doesn’t support asynchronous HTTP requests directly. If you need &lt;a href=&quot;https://realpython.com/async-io-python/&quot;&gt;async&lt;/a&gt; support in your program, you should try out &lt;a href=&quot;https://docs.aiohttp.org/en/stable/&quot;&gt;AIOHTTP&lt;/a&gt; or &lt;a href=&quot;https://www.python-httpx.org/async/&quot;&gt;HTTPX&lt;/a&gt;. The latter library is broadly compatible with Requests’ syntax.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Because Requests is a third-party library, you need to install it before you can use it in your code. As a good practice, you should install external packages into a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt;, but you may choose to install &lt;code&gt;requests&lt;/code&gt; into your global environment if you’re planning to use it across multiple projects.&lt;/p&gt;
&lt;p&gt;Whether you’re working in a virtual environment or not, you’ll need to install &lt;code&gt;requests&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;requests
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt; has finished installing &lt;code&gt;requests&lt;/code&gt;, you can use it in your application. Importing &lt;code&gt;requests&lt;/code&gt; looks like this:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now that you’re all set up, it’s time to begin your journey through Requests. Your first goal will be learning how to make a &lt;code&gt;GET&lt;/code&gt; request.&lt;/p&gt;
&lt;h2 id=&quot;the-get-request&quot;&gt;The GET Request&lt;a class=&quot;headerlink&quot; href=&quot;#the-get-request&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods&quot;&gt;HTTP methods&lt;/a&gt;, such as &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt;, determine which action you’re trying to perform when making an HTTP request. Besides &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt;, there are several other common methods that you’ll use later in this tutorial.&lt;/p&gt;
&lt;p&gt;One of the most common HTTP methods is &lt;code&gt;GET&lt;/code&gt;. The &lt;code&gt;GET&lt;/code&gt; method indicates that you’re trying to get or retrieve data from a specified resource. To make a &lt;code&gt;GET&lt;/code&gt; request using Requests, you can invoke &lt;code&gt;requests.get()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To test this out, you can make a &lt;code&gt;GET&lt;/code&gt; request to &lt;a href=&quot;https://docs.github.com/en/rest&quot;&gt;GitHub’s REST API&lt;/a&gt; by calling &lt;code&gt;get()&lt;/code&gt; with the following URL:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://api.github.com&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;Response [200]&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Congratulations! You’ve made your first request. Now you’ll dive a little deeper into the response of that request.&lt;/p&gt;
&lt;h2 id=&quot;the-response&quot;&gt;The Response&lt;a class=&quot;headerlink&quot; href=&quot;#the-response&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;Response&lt;/code&gt; is a powerful object for inspecting the results of the request. Make that same request again, but this time store the return value in a &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variable&lt;/a&gt; so that you can get a closer look at its attributes and behaviors:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-requests/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-requests/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics Exercises: Installing Packages With pip</title>
      <id>https://realpython.com/courses/basics-exercises-install-packages-with-pip/</id>
      <link href="https://realpython.com/courses/basics-exercises-install-packages-with-pip/"/>
      <updated>2024-02-27T14:00:00+00:00</updated>
      <summary>In this Python Basics Exercises video course, you&#x27;ll practice installing packages with pip. You&#x27;ll also practice creating virtual environments, making lists of requirements, and recreating a development environment.</summary>
      <content type="html">
        &lt;p&gt;So far on the &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics learning path&lt;/a&gt;, you&amp;rsquo;ve been working within the bounds of the Python standard library. Now it&amp;rsquo;s time to unlock packages that aren&amp;rsquo;t included with Python by default. To do that, you&amp;rsquo;ll need &lt;strong&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Many programming languages offer a &lt;strong&gt;package manager&lt;/strong&gt; that automates the process of installing, upgrading, and removing &lt;strong&gt;third-party packages&lt;/strong&gt;. Python is no exception. The de facto package manager for Python is called &lt;code&gt;pip&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;In this Python Basics Exercises course, you&amp;rsquo;ll test and reinforce your knowledge of installing packages and managing virtual environments.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll practice:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Installing&lt;/strong&gt; and &lt;strong&gt;managing&lt;/strong&gt; third-party packages with &lt;code&gt;pip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;virtual environments&lt;/strong&gt; to separate project dependencies&lt;/li&gt;
&lt;li&gt;Declaring &lt;strong&gt;requirements&lt;/strong&gt; and &lt;strong&gt;re-create&lt;/strong&gt; a development environment&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of this course, you&amp;rsquo;ll have an even stronger grasp of installing packages to suit your programming needs&lt;/p&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Duck Typing in Python: Writing Flexible and Decoupled Code</title>
      <id>https://realpython.com/duck-typing-python/</id>
      <link href="https://realpython.com/duck-typing-python/"/>
      <updated>2024-02-26T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about duck typing in Python. It&#x27;s a typing system based on objects&#x27; behaviors rather than on inheritance. By taking advantage of duck typing, you can create flexible and decoupled sets of Python classes that you can use together or individually.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python makes extensive use of a &lt;a href=&quot;https://realpython.com/python-type-checking/#type-systems&quot;&gt;type system&lt;/a&gt; known as &lt;strong&gt;duck typing&lt;/strong&gt;. The system is based on objects’ behaviors and interfaces. Many built-in classes and tools support this type system, which makes them pretty flexible and decoupled.&lt;/p&gt;
&lt;p&gt;Duck typing is a core concept in Python. Learning about the topic will help you understand how the language works and, more importantly, how to use this approach in your own code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;duck typing&lt;/strong&gt; is and what its pros and cons are&lt;/li&gt;
&lt;li&gt;How Python’s classes and tools &lt;strong&gt;take advantage of duck typing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;special methods&lt;/strong&gt; and &lt;strong&gt;protocols&lt;/strong&gt; support duck typing&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;alternatives&lt;/strong&gt; to duck typing you’ll have in Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with several Python concepts, including &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-magic-methods/&quot;&gt;special methods&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-interface/&quot;&gt;interfaces&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/duck-typing-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-duck-typing-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use duck typing in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-to-know-duck-typing-in-python&quot;&gt;Getting to Know Duck Typing in Python&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-duck-typing-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt; mainly aim to encapsulate data and behaviors. Following this idea, you can replace any object with another if the replacement provides the same behaviors. This is true even if the implementation of the underlying behavior is radically different.&lt;/p&gt;
&lt;p&gt;The code that uses the behaviors will work no matter what object provides it. This principle is the basis of a type system known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Duck_typing&quot;&gt;duck typing&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;duck-typing-behaving-like-a-duck&quot;&gt;Duck Typing: Behaving Like a Duck&lt;a class=&quot;headerlink&quot; href=&quot;#duck-typing-behaving-like-a-duck&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You’ll find many different definitions of duck typing out there. At its core, this coding style is based on a well-known saying:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If it walks like a duck and it quacks like a duck, then it must be a duck.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Extrapolating this to programming, you can have objects that &lt;em&gt;quack&lt;/em&gt; like a duck and &lt;em&gt;walk&lt;/em&gt; like a duck rather than asking whether those objects are ducks. In this context, &lt;em&gt;quack&lt;/em&gt; and &lt;em&gt;walk&lt;/em&gt; represent specific behaviors, which are part of the objects’ public interface (&lt;a href=&quot;https://en.wikipedia.org/wiki/API&quot;&gt;API&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Duck typing is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Type_system&quot;&gt;type system&lt;/a&gt; where an object is considered compatible with a given type if it has all the &lt;a href=&quot;https://realpython.com/python-classes/#providing-behavior-with-methods&quot;&gt;methods&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-classes/#attaching-data-to-classes-and-instances&quot;&gt;attributes&lt;/a&gt; that the type requires. This type system supports the ability to use objects of independent and decoupled classes in a specific context as long as they adhere to some common interface.&lt;/p&gt;
&lt;p&gt;Duck typing is pretty popular in Python. The language documentation defines duck typing as shown below:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A programming style which does not look at an object’s type to determine if it has the right interface; instead, the method or attribute is simply called or used (“If it looks like a duck and quacks like a duck, it must be a duck.”) By emphasizing interfaces rather than specific types, well-designed code improves its flexibility by allowing polymorphic substitution.&lt;/p&gt;
&lt;p&gt;Duck-typing avoids tests using &lt;a href=&quot;https://docs.python.org/3/library/functions.html#type&quot;&gt;&lt;code&gt;type()&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;https://docs.python.org/3/library/functions.html#isinstance&quot;&gt;&lt;code&gt;isinstance()&lt;/code&gt;&lt;/a&gt;. (Note, however, that duck-typing can be complemented with &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-abstract-base-class&quot;&gt;abstract base classes&lt;/a&gt;.) Instead, it typically employs &lt;a href=&quot;https://docs.python.org/3/library/functions.html#hasattr&quot;&gt;&lt;code&gt;hasattr()&lt;/code&gt;&lt;/a&gt; tests or &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-EAFP&quot;&gt;EAFP&lt;/a&gt; programming. (&lt;a href=&quot;https://docs.python.org/3/glossary.html#term-duck-typing&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here’s a quick example that involves birds that can swim and fly:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    &lt;span class=&quot;mr-2&quot; aria-label=&quot;Filename&quot;&gt;&lt;code style=&quot;color: inherit;&quot;&gt;birds_v1.py&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Duck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;swim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The duck is swimming&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The duck is flying&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Swan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;swim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The swan is swimming&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The swan is flying&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Albatross&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;swim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The albatross is swimming&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The albatross is flying&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, your three birds can swim and fly. However, they’re completely independent classes. Because they share the same interface, you can use them in a flexible manner:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;birds_v1&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Duck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Swan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Albatross&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;birds&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Duck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Swan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Albatross&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bird&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;birds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;bird&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;bird&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;swim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The duck is flying&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The duck is swimming&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The swan is flying&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The swan is swimming&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The albatross is flying&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The albatross is swimming&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Python doesn’t care about what object &lt;code&gt;bird&lt;/code&gt; is holding at a given time. It just calls the expected methods. If the object provides the method, then the code works without breaking. That’s the flexibility that duck typing offers.&lt;/p&gt;
&lt;p&gt;The duck typing system is pretty popular in Python. In most cases, you shouldn’t worry about making sure that an object is of the right type for using it in a certain piece of code. Instead, you can rely on objects that quack like ducks and walk like ducks.&lt;/p&gt;
&lt;h3 id=&quot;duck-typing-and-polymorphism&quot;&gt;Duck Typing and Polymorphism&lt;a class=&quot;headerlink&quot; href=&quot;#duck-typing-and-polymorphism&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In object-oriented programming, &lt;a href=&quot;https://en.wikipedia.org/wiki/Polymorphism_(computer_science)&quot;&gt;polymorphism&lt;/a&gt; allows you to treat objects of different types as the same general type. Polymorphism aims to enable code to work with objects of various types through a uniform interface (API), which helps you write more general and reusable code.&lt;/p&gt;
&lt;p&gt;You’ll find different &lt;a href=&quot;https://en.wikipedia.org/wiki/Polymorphism_(computer_science)#Forms&quot;&gt;forms&lt;/a&gt; of polymorphism in object-oriented programming. Duck typing is one of them.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/duck-typing-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/duck-typing-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #193: Wes McKinney on Improving the Data Stack &amp; Composable Systems</title>
      <id>https://realpython.com/podcasts/rpp/193/</id>
      <link href="https://realpython.com/podcasts/rpp/193/"/>
      <updated>2024-02-23T12:00:00+00:00</updated>
      <summary>How do you avoid the bottlenecks of data processing systems? Is it possible to build tools that decouple storage and computation? This week on the show, creator of the pandas library Wes McKinney is here to discuss Apache Arrow, composable data systems, and community collaboration.</summary>
      <content type="html">
        &lt;p&gt;How do you avoid the bottlenecks of data processing systems? Is it possible to build tools that decouple storage and computation? This week on the show, creator of the pandas library Wes McKinney is here to discuss Apache Arrow, composable data systems, and community collaboration.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Read User Input From the Keyboard in Python</title>
      <id>https://realpython.com/python-keyboard-input/</id>
      <link href="https://realpython.com/python-keyboard-input/"/>
      <updated>2024-02-21T14:00:00+00:00</updated>
      <summary>Reading user input from the keyboard is a valuable skill for a Python programmer, and you can create interactive and advanced programs that run on the terminal. In this tutorial, you&#x27;ll learn how to create robust user input programs, integrating error handling and multiple entries.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You may often want to make your Python programs more interactive by responding dynamically to input from the user. Learning how to read user input from the keyboard unlocks exciting possibilities and can make your code far more useful.&lt;/p&gt;
&lt;p&gt;The ability to gather input from the keyboard with Python allows you to build programs that can respond uniquely based on the preferences, decisions, or data provided by different users. By fetching input and assigning it to variables, your code can react to adjustable conditions rather than just executing static logic flows. This personalizes programs to individual users.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;input()&lt;/code&gt; function is the simplest way to get keyboard data from the user in Python. When called, it asks the user for input with a prompt that you specify, and it waits for the user to type a response and press the &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt; key before continuing. This response string is returned by &lt;code&gt;input()&lt;/code&gt; so you can save it to a variable or use it directly.&lt;/p&gt;
&lt;p&gt;Using only Python, you can start building interactive programs that accept customizable data from the user right within the terminal. Taking user input is an essential skill that unlocks more dynamic Python coding and allows you to elevate simple scripts into personalized applications.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-keyboard-input-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-keyboard-input-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to get user input from the keyboard with Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-read-keyboard-input-in-python-with-input&quot;&gt;How to Read Keyboard Input in Python With &lt;code&gt;input()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-read-keyboard-input-in-python-with-input&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can create robust and interactive programs by taking advantage of &lt;code&gt;input()&lt;/code&gt;. It opens up possibilities for creating scripts that respond dynamically based on adjustable conditions, personalized data, and real-time decision-making from the user. It is an ideal option when you want to read keyboard input with Python.&lt;/p&gt;
&lt;p&gt;Getting started is straightforward. Just launch the Python interpreter shell, and you can immediately utilize &lt;code&gt;input()&lt;/code&gt; for basic interactivity.&lt;/p&gt;
&lt;p&gt;To try it, first open your &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt; and launch the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;Python REPL&lt;/a&gt; by typing &lt;code&gt;python&lt;/code&gt; and hitting &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt;. This will display the familiar &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; Python prompt indicating the REPL is ready. Use &lt;code&gt;input()&lt;/code&gt;, passing any string in the parentheses:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;What is your name? &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;What is your name? Vincent&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;&#x27;Vincent&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once you execute the code, the string that you specified in &lt;code&gt;input()&lt;/code&gt; will be rendered on screen, and you’ll be able to type in any response. Your response will also print to the screen once you press &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt;. This is because the REPL automatically prints return values—in this case, the value returned by &lt;code&gt;input()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The best practice when using &lt;code&gt;input()&lt;/code&gt; is to assign it to a variable that you can use later in your code. For example, you can ask the user to type in their name. Assign &lt;code&gt;input()&lt;/code&gt; to the &lt;code&gt;name&lt;/code&gt; variable:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;What is your name? &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;What is your name? Vincent&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This prints the prompt &lt;em&gt;What is your name?&lt;/em&gt; and pauses, waiting for keyboard input. After the user types a name and presses &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt;, the text string is stored in the &lt;code&gt;name&lt;/code&gt; variable. This time, your input won’t automatically print in the REPL, because a variable stores the value instead.&lt;/p&gt;
&lt;p&gt;You can now use the variable in any part of your code in the same session, like printing a personalized greeting:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello there, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello there, Vincent!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Your program reacted based on the custom name that you provided. It used the name that you gave in the &lt;code&gt;input()&lt;/code&gt; request.&lt;/p&gt;
&lt;p&gt;This is the essential pattern when working with Python keyboard input:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Call &lt;code&gt;input()&lt;/code&gt; with a prompt explaining what to enter.&lt;/li&gt;
&lt;li&gt;Assign the result to a descriptively named variable.&lt;/li&gt;
&lt;li&gt;Use that variable later in your code.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By following this template, you can start building all types of interactive scripts tailored to custom data from different users. Your programs can gather input of all types, such as names, numbers, and lists, making it quite handy in processing data from your users.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Using &lt;code&gt;input()&lt;/code&gt; processes all inputs as string literals, the users’ input isn’t executed as code. However, you should be wary of users’ inputs and assess them before executing them in your program, using them in database queries, or otherwise trusting them. &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This is just the initial step that you can take in using &lt;code&gt;input()&lt;/code&gt; in your interactive program. There are other modifications that you can make to ensure that the function takes in all manner of data types.&lt;/p&gt;
&lt;h2 id=&quot;reading-specific-data-types-with-the-input-function&quot;&gt;Reading Specific Data Types With the Input Function&lt;a class=&quot;headerlink&quot; href=&quot;#reading-specific-data-types-with-the-input-function&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The general rule for &lt;code&gt;input()&lt;/code&gt; is that it collects textual input and delivers strings. Your code often needs numbers, Booleans or other data types instead. For example, maybe you need to get &lt;a href=&quot;https://realpython.com/python-input-integer/&quot;&gt;integers&lt;/a&gt; for math operations, &lt;a href=&quot;https://realpython.com/python-numbers/#floating-point-numbers&quot;&gt;floats&lt;/a&gt; for calculations with decimals, or &lt;a href=&quot;https://realpython.com/python-boolean/&quot;&gt;Booleans&lt;/a&gt; for logical conditions.&lt;/p&gt;
&lt;p&gt;As &lt;code&gt;input()&lt;/code&gt; returns strings, you need to convert all the input into the targeted desired data type before using it in your code. If you ask for numerical input, the outcome will still be returned as a string:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-keyboard-input/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-keyboard-input/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Unleashing the Power of the Console With Rich</title>
      <id>https://realpython.com/courses/unleash-power-rich/</id>
      <link href="https://realpython.com/courses/unleash-power-rich/"/>
      <updated>2024-02-20T14:00:00+00:00</updated>
      <summary>Rich is a powerful library for creating text-based user interfaces (TUIs) in Python. It enhances code readability by pretty-printing complex data structures and adds visual appeal with colored text, tables, animations, and more.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s Rich package is a versatile tool kit that enables you to generate beautifully formatted and highlighted text in the console. It extends beyond this to help you build captivating text-based user interfaces (TUIs).&lt;/p&gt;
&lt;p&gt;But why opt for a TUI instead of a graphical user interface (GUI)? There are instances where a text interface feels more fitting. Why employ a complex GUI for a simple application when an elegant text interface suffices? Working with plain text can be refreshing. It functions effortlessly across various hardware environments, including SSH terminals and single-board computer displays.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll discover how Rich can benefit you by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Enhancing the user interface of command-line tools&lt;/li&gt;
&lt;li&gt;Improving the legibility of console output&lt;/li&gt;
&lt;li&gt;Creating appealing dashboard displays for real-time tabular data&lt;/li&gt;
&lt;li&gt;Generating well-formatted reports&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Dependency Management With Python Poetry</title>
      <id>https://realpython.com/dependency-management-python-poetry/</id>
      <link href="https://realpython.com/dependency-management-python-poetry/"/>
      <updated>2024-02-19T14:00:00+00:00</updated>
      <summary>Learn how Python Poetry will help you start new projects, maintain existing ones, and master dependency management.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When your Python project relies on external packages, you need to make sure you’re using the right version of each package. After an update, a package might not work as it did before. A &lt;strong&gt;dependency manager&lt;/strong&gt; like Python Poetry helps you specify, install, and resolve external packages in your projects. This way, you can be sure that you always work with the correct dependency version on every machine.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;strong&gt;new project&lt;/strong&gt; using Poetry&lt;/li&gt;
&lt;li&gt;Add Poetry to an &lt;strong&gt;existing project&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Configure your project through &lt;strong&gt;&lt;code&gt;pyproject.toml&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Pin your project’s &lt;strong&gt;dependency versions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Install dependencies from a &lt;strong&gt;&lt;code&gt;poetry.lock&lt;/code&gt;&lt;/strong&gt; file&lt;/li&gt;
&lt;li&gt;Run basic Poetry commands using the &lt;strong&gt;Poetry CLI&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;https://python-poetry.org/&quot;&gt;Poetry&lt;/a&gt; helps you create new projects or maintain existing projects while taking care of &lt;strong&gt;dependency management&lt;/strong&gt; for you. It uses the &lt;code&gt;pyproject.toml&lt;/code&gt; file, which has become the standard for defining build requirements in modern Python projects.&lt;/p&gt;
&lt;p&gt;To complete this tutorial and get the most out of it, you should have a basic understanding of &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environments&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;modules and packages&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;While you’ll focus on dependency management in this tutorial, Poetry can also help you &lt;a href=&quot;https://python-poetry.org/docs/cli/#build&quot;&gt;build a distribution package&lt;/a&gt; for your project. If you want to share your work, then you can use Poetry to &lt;a href=&quot;https://python-poetry.org/docs/cli/#publish&quot;&gt;publish&lt;/a&gt; your project on the &lt;a href=&quot;https://pypi.org/&quot;&gt;Python Packaging Index (PyPI)&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-dependency-pitfalls-email-course&quot; data-focus=&quot;false&quot;&gt;Click here to get access to a free 5-day class&lt;/a&gt; that shows you how to avoid common dependency management issues with tools like Pip, PyPI, Virtualenv, and requirements files.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;take-care-of-prerequisites&quot;&gt;Take Care of Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#take-care-of-prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before diving into the nitty-gritty of Python Poetry, you’ll take care of some prerequisites. First, you’ll read a short overview of the terminology that you’ll encounter in this tutorial. Next, you’ll install Poetry itself.&lt;/p&gt;
&lt;h3 id=&quot;learn-the-relevant-terminology&quot;&gt;Learn the Relevant Terminology&lt;a class=&quot;headerlink&quot; href=&quot;#learn-the-relevant-terminology&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you’ve ever used an &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;&lt;code&gt;import&lt;/code&gt; statement&lt;/a&gt; in one of your Python scripts, then you’ve worked with &lt;strong&gt;modules&lt;/strong&gt; and &lt;strong&gt;packages&lt;/strong&gt;. Some of them might have been Python files you wrote on your own. Others could’ve been &lt;strong&gt;standard library modules&lt;/strong&gt; that ship with Python, like &lt;a href=&quot;https://realpython.com/python-datetime/&quot;&gt;&lt;code&gt;datetime&lt;/code&gt;&lt;/a&gt;. However, sometimes, what Python provides isn’t enough. That’s when you might turn to external modules and packages maintained by third parties.&lt;/p&gt;
&lt;p&gt;When your Python code relies on such external modules and packages, they become the &lt;strong&gt;requirements&lt;/strong&gt; or &lt;strong&gt;dependencies&lt;/strong&gt; of your project.&lt;/p&gt;
&lt;p&gt;To find packages contributed by the Python community that aren’t part of the &lt;a href=&quot;https://docs.python.org/3/py-modindex.html&quot;&gt;Python standard library&lt;/a&gt;, you can browse &lt;a href=&quot;https://pypi.org/&quot;&gt;PyPI&lt;/a&gt;. Once you’ve found a package you’re interested in, you can use Poetry to manage and install that package in your project. Before seeing how this works, you need to install Poetry on your system.&lt;/p&gt;
&lt;h3 id=&quot;install-poetry-on-your-computer&quot;&gt;Install Poetry on Your Computer&lt;a class=&quot;headerlink&quot; href=&quot;#install-poetry-on-your-computer&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Poetry is distributed as a &lt;a href=&quot;https://pypi.org/project/poetry/&quot;&gt;Python package itself&lt;/a&gt;, which means that you can install it into a virtual environment using &lt;code&gt;pip&lt;/code&gt;, just like any other external package:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-1&quot; role=&quot;tab&quot; aria-controls=&quot;windows-1&quot; aria-selected=&quot;true&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#brands--windows&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Windows&lt;/a&gt;
  &lt;/li&gt;




  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linuxmacos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-macos-1&quot; role=&quot;tab&quot; aria-controls=&quot;linux-macos-1&quot; aria-selected=&quot;false&quot;&gt;&lt;span class=&quot;icon baseline text-muted&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#v4--apple&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-1&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pscon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Windows PowerShell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;PS&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;python&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pip&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poetry&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-macos-tab-1&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-macos-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python3&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;poetry
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is fine if you just want to quickly try it out. However, the &lt;a href=&quot;https://python-poetry.org/docs/&quot;&gt;official documentation&lt;/a&gt; strongly advises &lt;em&gt;against&lt;/em&gt; installing Poetry into your project’s virtual environment, which the tool must manage. Because Poetry depends on several external packages itself, you’d run the risk of a &lt;strong&gt;dependency conflict&lt;/strong&gt; between one of your project’s dependencies and those required by Poetry. In turn, this could cause Poetry or your code to malfunction.&lt;/p&gt;
&lt;p&gt;In practice, you always want to keep Poetry separate from any virtual environment that you create for your Python projects. You also want to install Poetry &lt;strong&gt;system-wide&lt;/strong&gt; to access it as a stand-alone application regardless of the specific virtual environment or Python version that you’re currently working in.&lt;/p&gt;
&lt;p&gt;There are several ways to get Poetry running on your computer, including:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A tool called &lt;code&gt;pipx&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The official installer&lt;/li&gt;
&lt;li&gt;Manual installation&lt;/li&gt;
&lt;li&gt;Pre-built system packages&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In most cases, the &lt;em&gt;recommended way to install Poetry&lt;/em&gt; is with the help of &lt;code&gt;pipx&lt;/code&gt;, which takes care of creating and maintaining isolated virtual environments for command-line Python applications. After &lt;a href=&quot;https://pipx.pypa.io/stable/installation/&quot;&gt;installing &lt;code&gt;pipx&lt;/code&gt;&lt;/a&gt;, you can install Poetry by issuing the following command in your terminal window:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-2&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-2&quot; role=&quot;tab&quot; aria-controls=&quot;windows-2&quot; aria-selected=&quot;true&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#brands--windows&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Windows&lt;/a&gt;
  &lt;/li&gt;




  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linuxmacos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-2&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-macos-2&quot; role=&quot;tab&quot; aria-controls=&quot;linux-macos-2&quot; aria-selected=&quot;false&quot;&gt;&lt;span class=&quot;icon baseline text-muted&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#v4--apple&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-2&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-2&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pscon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Windows PowerShell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;PS&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pipx&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poetry&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-macos-tab-2&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-macos-2&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pipx&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;poetry
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.06c57406e4fc.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;While this command looks very similar to the one you saw previously, it’ll install Poetry into a dedicated virtual environment that won’t be shared with other Python packages.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/dependency-management-python-poetry/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/dependency-management-python-poetry/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #192: Practical Python Decorator Uses &amp; Avoiding datetime Pitfalls</title>
      <id>https://realpython.com/podcasts/rpp/192/</id>
      <link href="https://realpython.com/podcasts/rpp/192/"/>
      <updated>2024-02-16T12:00:00+00:00</updated>
      <summary>What are real-life examples of using Python decorators? How can you harness their power in your code? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What are real-life examples of using Python decorators? How can you harness their power in your code? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Create Conway&#x27;s Game of Life With Python</title>
      <id>https://realpython.com/courses/conway-game-of-life-python/</id>
      <link href="https://realpython.com/courses/conway-game-of-life-python/"/>
      <updated>2024-02-13T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll use Python to build Conway&#x27;s Game of Life. You&#x27;ll implement a user-friendly command-line interface (CLI) with several options that will allow you to run the game using different life patterns and configurations.</summary>
      <content type="html">
        &lt;p&gt;Wouldn&amp;rsquo;t it be cool to build a Python game that only requires initial user input and then seems to take on a mind of its own, creating mesmerizing patterns along the way? You can do exactly that with &lt;a href=&quot;https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life&quot;&gt;Conway&amp;rsquo;s Game of Life&lt;/a&gt;, which is about the evolution of cells in a life grid.&lt;/p&gt;
&lt;p&gt;Implementing the Game of Life algorithm is a good exercise with many interesting challenges that you&amp;rsquo;ll have to figure out. Specifically, you&amp;rsquo;ll need to build the life grid and find a way to apply the game&amp;rsquo;s rules to all the cells on the grid so that they evolve through several generations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement Conway&amp;rsquo;s &lt;strong&gt;Game of Life algorithm&lt;/strong&gt; with Python&lt;/li&gt;
&lt;li&gt;Build a &lt;strong&gt;&lt;code&gt;curses&lt;/code&gt; view&lt;/strong&gt; to display the Game of Life grid&lt;/li&gt;
&lt;li&gt;Create an &lt;strong&gt;&lt;code&gt;argparse&lt;/code&gt; command-line interface&lt;/strong&gt; for the game&lt;/li&gt;
&lt;li&gt;Set up the game app for &lt;strong&gt;installation&lt;/strong&gt; and &lt;strong&gt;execution&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this video course, you should know the basics of writing &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented code&lt;/a&gt; in Python, creating command-line interface (CLI) apps with &lt;a href=&quot;https://realpython.com/command-line-interfaces-python-argparse/&quot;&gt;&lt;code&gt;argparse&lt;/code&gt;&lt;/a&gt;, and setting up a Python project.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #191: Focusing on Data Science &amp; Less on Engineering and Dependencies</title>
      <id>https://realpython.com/podcasts/rpp/191/</id>
      <link href="https://realpython.com/podcasts/rpp/191/"/>
      <updated>2024-02-09T12:00:00+00:00</updated>
      <summary>How do you manage the dependencies of a large-scale data science project? How do you migrate that project from a laptop to cloud infrastructure or utilize GPUs and multiple instances in parallel? This week on the show, Savin Goyal returns to discuss the updates to the open-source framework Metaflow.</summary>
      <content type="html">
        &lt;p&gt;How do you manage the dependencies of a large-scale data science project? How do you migrate that project from a laptop to cloud infrastructure or utilize GPUs and multiple instances in parallel? This week on the show, Savin Goyal returns to discuss the updates to the open-source framework Metaflow.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics Exercises: Lists and Tuples</title>
      <id>https://realpython.com/courses/python-basics-exercises-lists-tuples/</id>
      <link href="https://realpython.com/courses/python-basics-exercises-lists-tuples/"/>
      <updated>2024-02-06T14:00:00+00:00</updated>
      <summary>In this Python Basics Exercises video course, you&#x27;ll practice defining and manipulating Python lists and tuples in your code. By reinforcing your skills, you&#x27;ll gain confidence in using lists and tuples in your programming projects.</summary>
      <content type="html">
        &lt;p&gt;In &lt;a href=&quot;https://realpython.com/courses/python-basics-lists-tuples/&quot;&gt;Python Basics: Lists and Tuples&lt;/a&gt;, you learned that &lt;strong&gt;Python lists&lt;/strong&gt; resemble real-life lists in many ways. They serve as containers for organizing and storing collections of objects, allowing for the inclusion of different data types. You also learned about &lt;strong&gt;tuples&lt;/strong&gt;, which are also collections of objects. However, while lists are &lt;strong&gt;mutable&lt;/strong&gt;, tuples are &lt;strong&gt;immutable&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In this Python Basics Exercises course, you&amp;rsquo;ll test and reinforce your knowledge of Python lists and tuples. Along the way, you&amp;rsquo;ll also get experience with some good programming practices that will help you solve future challenges.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll practice:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Defining and manipulating lists and tuples in Python&lt;/li&gt;
&lt;li&gt;Leveraging the unique qualities of lists and tuples&lt;/li&gt;
&lt;li&gt;Determining when you should use lists vs tuples&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of this course, you&amp;rsquo;ll have an even stronger grasp of Python lists and tuples. You&amp;rsquo;ll be equipped with the knowledge to effectively incorporate them into your own programming projects.&lt;/p&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. You can also check out the other &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics courses&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #190: Great Starting Points for Contributing to Open Source</title>
      <id>https://realpython.com/podcasts/rpp/190/</id>
      <link href="https://realpython.com/podcasts/rpp/190/"/>
      <updated>2024-02-02T12:00:00+00:00</updated>
      <summary>What&#x27;s it like to sit down for your first developer sprint at a conference? How do you find an appropriate issue to work on as a new open-source contributor? This week on the show, author and software engineer Stefanie Molin is here to discuss starting to contribute to open-source projects.</summary>
      <content type="html">
        &lt;p&gt;What&#x27;s it like to sit down for your first developer sprint at a conference? How do you find an appropriate issue to work on as a new open-source contributor? This week on the show, author and software engineer Stefanie Molin is here to discuss starting to contribute to open-source projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Building Enumerations With Python&#x27;s enum</title>
      <id>https://realpython.com/courses/python-enum/</id>
      <link href="https://realpython.com/courses/python-enum/"/>
      <updated>2024-01-30T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll discover the art of creating and using enumerations of logically connected constants in Python. To accomplish this, you&#x27;ll explore the Enum class and other associated tools and types from the enum module from the Python standard library.</summary>
      <content type="html">
        &lt;p&gt;Some programming languages, such as Java and C++, have built-in support for a data type called &lt;strong&gt;enumerations&lt;/strong&gt;, commonly referred to as &lt;strong&gt;enums&lt;/strong&gt;. Enums enable you to create sets of logically related constants that you can access through the enumeration itself. Unlike these languages, Python doesn&amp;rsquo;t have a dedicated syntax for enums. However, the Python &lt;a href=&quot;https://docs.python.org/3/library/index.html&quot;&gt;standard library&lt;/a&gt; provides an &lt;code&gt;enum&lt;/code&gt; module that offers support for enumerations through the &lt;code&gt;Enum&lt;/code&gt; class.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re familiar with enums from other languages and wish to use them in Python, or if you simply want to learn how to work with enumerations, then this video course is designed for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll discover how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;strong&gt;enumerations&lt;/strong&gt; of constants using Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;Enum&lt;/code&gt;&lt;/strong&gt; class&lt;/li&gt;
&lt;li&gt;Interact with enumerations and their &lt;strong&gt;members&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Customize enumeration classes by adding &lt;strong&gt;new functionalities&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Apply &lt;strong&gt;practical examples&lt;/strong&gt; to gain a deeper understanding of the benefits of using enumerations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, you&amp;rsquo;ll explore other specific enumeration types available in the &lt;code&gt;enum&lt;/code&gt; module, such as &lt;code&gt;IntEnum&lt;/code&gt;, &lt;code&gt;IntFlag&lt;/code&gt;, and &lt;code&gt;Flag&lt;/code&gt;. These specialized enums will expand your repertoire.&lt;/p&gt;
&lt;p&gt;To get the most out of this video course, you should be familiar with &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt; in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #189: Building a Python Debugger &amp; Preparing for NumPy 2.0</title>
      <id>https://realpython.com/podcasts/rpp/189/</id>
      <link href="https://realpython.com/podcasts/rpp/189/"/>
      <updated>2024-01-26T12:34:00+00:00</updated>
      <summary>How does a debugger work? What can you learn about Python by building one from scratch? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How does a debugger work? What can you learn about Python by building one from scratch? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Lists and Tuples</title>
      <id>https://realpython.com/courses/python-basics-lists-tuples/</id>
      <link href="https://realpython.com/courses/python-basics-lists-tuples/"/>
      <updated>2024-01-23T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about Python lists and tuples, including how to define and manipulate them in your code. By the end of the course, you&#x27;ll be ready to effectively use lists and tuples in your programming projects.</summary>
      <content type="html">
        &lt;p&gt;&lt;strong&gt;Python lists&lt;/strong&gt; are similar to real-life lists. You can use them to store and organize a collection of objects, which can be of any data type. Instead of just storing one item, a list can hold multiple items while allowing manipulation and retrieval of those items. Because lists are &lt;strong&gt;mutable&lt;/strong&gt;, you can think of them as being written in pencil. In other words, you can make changes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tuples&lt;/strong&gt;, on the other hand, are written in ink. They&amp;rsquo;re similar to lists in that they can hold multiple items, but unlike lists, tuples are &lt;strong&gt;immutable&lt;/strong&gt;, meaning you can&amp;rsquo;t modify them after you&amp;rsquo;ve created them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What lists and tuples are and how they&amp;rsquo;re structured&lt;/li&gt;
&lt;li&gt;How lists and tuples differ from other data structures&lt;/li&gt;
&lt;li&gt;How to define and manipulate lists and tuples in your Python code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of this course, you&amp;rsquo;ll have a solid understanding of Python lists and tuples, and you&amp;rsquo;ll be able to use them effectively in your own programming projects.&lt;/p&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. You can also check out the other &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics courses&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #188: Measuring Bias, Toxicity, and Truthfulness in LLMs With Python</title>
      <id>https://realpython.com/podcasts/rpp/188/</id>
      <link href="https://realpython.com/podcasts/rpp/188/"/>
      <updated>2024-01-19T12:00:00+00:00</updated>
      <summary>How can you measure the quality of a large language model? What tools can measure bias, toxicity, and truthfulness levels in a model using Python? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to discuss techniques and tools for evaluating LLMs With Python.</summary>
      <content type="html">
        &lt;p&gt;How can you measure the quality of a large language model? What tools can measure bias, toxicity, and truthfulness levels in a model using Python? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to discuss techniques and tools for evaluating LLMs With Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Create a Tic-Tac-Toe Python Game Engine With an AI Player</title>
      <id>https://realpython.com/courses/python-tic-tac-toe-ai/</id>
      <link href="https://realpython.com/courses/python-tic-tac-toe-ai/"/>
      <updated>2024-01-16T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll create a universal game engine in Python for tic-tac-toe with two computer players, one of which will be an AI player using the powerful minimax algorithm. You&#x27;ll give your game library a text-based graphical interface and explore two front ends.</summary>
      <content type="html">
        &lt;p&gt;A classic childhood game is tic-tac-toe, also known as naughts and crosses. It&amp;rsquo;s simple and enjoyable, and coding a version of it with Python is an exciting project for a budding programmer. Now, adding some artificial intelligence (AI) using Python can make an old favorite even more thrilling.&lt;/p&gt;
&lt;p&gt;In this comprehensive tutorial, you&amp;rsquo;ll construct a flexible game engine. This engine will include an unbeatable computer player that employs the minimax algorithm to play tic-tac-toe flawlessly. Throughout the tutorial, you&amp;rsquo;ll explore concepts such as immutable class design, generic plug-in architecture, and modern Python coding practices and patterns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Develop a reusable &lt;strong&gt;Python library&lt;/strong&gt; containing the tic-tac-toe game engine&lt;/li&gt;
&lt;li&gt;Create a Pythonic code style that accurately models the tic-tac-toe &lt;strong&gt;domain&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implement various artificial players, including one using the powerful &lt;strong&gt;minimax algorithm&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Construct a text-based &lt;strong&gt;console front end&lt;/strong&gt; for the game, enabling human players to participate&lt;/li&gt;
&lt;li&gt;Discover effective strategies for &lt;strong&gt;optimizing performance&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Are you ready to embark on this step-by-step adventure of building an extensible game engine with an unbeatable AI player using the minimax algorithm?&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  

</feed>
