<?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-02-28T14:00:00+00:00</updated>
  <id>https://realpython.com/</id>
  <author>
    <name>Real Python</name>
  </author>

  
    <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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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.827db10c169f.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>BNF Notation: Dive Deeper Into Python&#x27;s Grammar</title>
      <id>https://realpython.com/python-bnf-notation/</id>
      <link href="https://realpython.com/python-bnf-notation/"/>
      <updated>2024-02-14T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about Backus–Naur form notation (BNF), which is typically used for defining the grammar of programming languages. Python uses a variation of BNF, and here, you&#x27;ll learn how to read it to get a better understanding of some language constructs.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;While reading the Python documentation, you may have found fragments of BNF notation (&lt;a href=&quot;https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form&quot;&gt;Backus–Naur form&lt;/a&gt;) that look something like the following:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;abnf&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;BNF Grammar&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;nc&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;::&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;lc_&lt;span class=&quot;nc&quot;&gt;letter&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;lc_&lt;span class=&quot;nc&quot;&gt;letter&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;|&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;l&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
lc_&lt;span class=&quot;nc&quot;&gt;letter&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;::&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;l&quot;&gt;&quot;a&quot;&lt;/span&gt;...&lt;span class=&quot;l&quot;&gt;&quot;z&quot;&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.827db10c169f.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.827db10c169f.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;What’s the meaning of all this strange code? How can this help you in understanding Python concepts? How can you read and interpret this notation?&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll get to know the basics of Python’s BNF notation and learn how to take advantage of it to get a deep understanding of the language’s syntax and grammar.&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;Learn what &lt;strong&gt;BNF notation&lt;/strong&gt; is and what it’s used for&lt;/li&gt;
&lt;li&gt;Explore the characteristics of &lt;strong&gt;Python’s BNF variation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Learn how to &lt;strong&gt;read&lt;/strong&gt; the BNF notation in the Python documentation&lt;/li&gt;
&lt;li&gt;Explore some &lt;strong&gt;best practices&lt;/strong&gt; for reading Python’s BNF notation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with Python syntax, including &lt;a href=&quot;https://realpython.com/python-keywords/&quot;&gt;keywords&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-operators-expressions/&quot;&gt;operators&lt;/a&gt;, and some common constructs like expressions, &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional&lt;/a&gt; statements, and &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;loops&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/python-bnf-notation-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-bnf-notation-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 read Python’s BNF notation.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-to-know-backus-naur-form-notation-bnf&quot;&gt;Getting to Know Backus-Naur Form Notation (BNF)&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-backus-naur-form-notation-bnf&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form&quot;&gt;Backus–Naur form&lt;/a&gt; or &lt;strong&gt;Backus normal form&lt;/strong&gt; (&lt;strong&gt;BNF&lt;/strong&gt;) is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Metasyntax&quot;&gt;metasyntax&lt;/a&gt; notation for &lt;a href=&quot;https://en.wikipedia.org/wiki/Context-free_grammar&quot;&gt;context-free grammars&lt;/a&gt;. Computer scientists often use this notation to describe the syntax of programming languages because it allows them to write a detailed description of a language’s grammar.&lt;/p&gt;
&lt;p&gt;The BNF notation consists of three core pieces:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols#Terminal_symbols&quot;&gt;Terminals&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Strings that must exactly match specific items in the input.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&quot;def&quot;&lt;/code&gt;, &lt;code&gt;&quot;return&quot;&lt;/code&gt;, &lt;code&gt;&quot;:&quot;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols#Nonterminal_symbols&quot;&gt;Nonterminals&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Symbols that will be replaced by a concrete value. They may also be called simply &lt;strong&gt;syntactic variables&lt;/strong&gt;.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;letter&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;digit&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols#Production_rules&quot;&gt;Rules&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Conventions of terminals and nonterminals that define how these elements relate.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;letter&amp;gt; ::= &quot;a&quot;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;By combining terminals and nonterminals, you can create &lt;strong&gt;BNF rules&lt;/strong&gt;, which can get as detailed as you need. Nonterminals must have their own defining rules. In a piece of grammar, you’ll have a root rule and potentially many secondary rules that define the required nonterminals. This way, you may end up with a hierarchy of rules.&lt;/p&gt;
&lt;p&gt;BNF rules are the core components of a BNF grammar. So, a &lt;strong&gt;grammar&lt;/strong&gt; is a set of BNF rules that are also called &lt;strong&gt;production rules&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In practice, you can build a set of BNF rules to specify the grammar of a language. Here, &lt;strong&gt;language&lt;/strong&gt; refers to a set of strings that are valid according to the rules defined in the corresponding grammar. BNF is mainly used for &lt;a href=&quot;https://en.wikipedia.org/wiki/Programming_language&quot;&gt;programming languages&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, the Python syntax has a &lt;a href=&quot;https://docs.python.org/3/reference/grammar.html&quot;&gt;grammar&lt;/a&gt; that’s defined as a set of BNF rules, and these rules are used to validate the syntax of any piece of Python code. If the code doesn’t fulfill the rules, then you’ll get a &lt;a href=&quot;https://realpython.com/invalid-syntax-python/&quot;&gt;&lt;code&gt;SyntaxError&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You’ll find many variations of the original BNF notation out there. Some of the most relevant include the &lt;a href=&quot;https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form&quot;&gt;extended Backus–Naur form&lt;/a&gt; (EBNF) and &lt;a href=&quot;https://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_form&quot;&gt;augmented Backus–Naur form&lt;/a&gt; (ABNF).&lt;/p&gt;
&lt;p&gt;In the following sections, you’ll learn the basics of creating BNF rules. Note that you’ll use a variation of BNF that matches the requirements of the &lt;a href=&quot;https://bnfplayground.pauliankline.com/&quot;&gt;BNF Playground&lt;/a&gt; site, which you’ll use for testing your rules.&lt;/p&gt;
&lt;h3 id=&quot;bnf-rules-and-their-components&quot;&gt;BNF Rules and Their Components&lt;a class=&quot;headerlink&quot; href=&quot;#bnf-rules-and-their-components&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As you already learned, by combining terminals and nonterminals, you can create BNF rules. These rules typically follow the syntax below:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;abnf&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;BNF Grammar&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;&amp;lt;&lt;span class=&quot;nc&quot;&gt;symbol&lt;/span&gt;&amp;gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;::&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;expression&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.827db10c169f.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.827db10c169f.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 the BNF rule syntax, you have the following parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Symbol&quot;&gt;&lt;code&gt;&amp;lt;symbol&amp;gt;&lt;/code&gt;&lt;/a&gt; is a nonterminal variable, which is often enclosed in angle brackets (&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;::=&lt;/code&gt; means that the nonterminal on the left will be replaced with the expression on the right.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Expression_(mathematics)&quot;&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/a&gt; consists of a series of terminals, nonterminals, and other symbols that define a specific piece of grammar.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When building BNF rules, you can use a variety of symbols with specific meanings. For example, if you’re going to use the BNF Playground site to compile and test your rules, then you’ll find yourself using some of the following symbols:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&quot;&quot;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Encloses a terminal symbol&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Indicates a nonterminal symbol&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Indicates a group of valid options&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;+&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies one or more of the previous element&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies zero or more of the previous element&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;?&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies zero or one occurrence of the previous element&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;|&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Indicates that you can select one of the options&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[x-z]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Indicates letter or digit intervals&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-bnf-notation/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-bnf-notation/ »&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>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>Primer on Python Decorators</title>
      <id>https://realpython.com/primer-on-python-decorators/</id>
      <link href="https://realpython.com/primer-on-python-decorators/"/>
      <updated>2024-02-12T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll look at what Python decorators are and how you define and use them. Decorators can make your code more readable and reusable. Come take a look at how decorators work under the hood and practice writing your own decorators.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In this tutorial on Python decorators, you’ll learn what they are and how to create and use them. Decorators provide a simple syntax for calling &lt;a href=&quot;http://en.wikipedia.org/wiki/Higher-order_function&quot;&gt;higher-order functions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it. This sounds confusing, but it’ll make more sense after you’ve seen a few examples of how decorators work. &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 it means for functions to be &lt;strong&gt;first-class objects&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to define functions so they can be used as &lt;strong&gt;decorators&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Which &lt;strong&gt;practical use cases&lt;/strong&gt; can be tackled with decorators&lt;/li&gt;
&lt;li&gt;How to create decorators so that they follow &lt;strong&gt;best practices&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can find all the examples from this tutorial by downloading the accompanying materials 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/primer-on-python-decorators-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-primer-on-python-decorators-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 create and use Python decorators.&lt;/p&gt;
&lt;/div&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-power-of-decorators-fixed&quot; data-focus=&quot;false&quot;&gt;Click here to get access to a free &quot;The Power of Python Decorators&quot; guide&lt;/a&gt; that shows you three advanced decorator patterns and techniques you can use to write cleaner and more Pythonic programs.&lt;/p&gt;&lt;/div&gt;

&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Decorators Cheat Sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/decorators-cheatsheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-decorators-cheatsheet&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to a free three-page Python decorators cheat sheet&lt;/a&gt; that summarizes the techniques explained in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Decorators Q&amp;amp;A Transcript:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/decorators-qa-2019/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-decorators-qa-2019&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to a 25-page chat log from our Python decorators Q&amp;amp;A session&lt;/a&gt; in the Real Python Community Slack where we discussed common decorator questions.&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.827db10c169f.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 “Decorators” 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/decorators/&quot; target=&quot;_blank&quot;&gt;Take the Quiz »&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;python-functions&quot;&gt;Python Functions&lt;a class=&quot;headerlink&quot; href=&quot;#python-functions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In order to understand decorators, you must first understand some finer points of how functions work. There are many aspects to functions, but in the context of decorators, &lt;strong&gt;a function returns a value based on the given arguments&lt;/strong&gt;. Here’s a basic example:&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.827db10c169f.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;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add_one&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&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;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&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;n&quot;&gt;add_one&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;3&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.827db10c169f.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.827db10c169f.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 general, functions in Python may also have side effects rather than just turning an input into an output. &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;The &lt;code&gt;print()&lt;/code&gt; function&lt;/a&gt; is an example of this: it &lt;a href=&quot;https://realpython.com/python-return-statement/&quot;&gt;returns&lt;/a&gt; &lt;a href=&quot;https://realpython.com/null-in-python/&quot;&gt;&lt;code&gt;None&lt;/code&gt;&lt;/a&gt; while having the side effect of outputting something to the console. However, to understand decorators, it’s enough to think about functions as tools that turn given arguments into values.&lt;/p&gt;
&lt;h3 id=&quot;first-class-objects&quot;&gt;First-Class Objects&lt;a class=&quot;headerlink&quot; href=&quot;#first-class-objects&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In &lt;a href=&quot;https://realpython.com/python-functional-programming/&quot;&gt;functional programming&lt;/a&gt;, you work almost entirely with pure functions that don’t have side effects. While not a purely functional language, Python supports many functional programming concepts, including treating functions as &lt;a href=&quot;https://dbader.org/blog/python-first-class-functions&quot;&gt;first-class objects&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;This means that &lt;em&gt;functions can be passed around and used as arguments&lt;/em&gt;, just like &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;any other object like &lt;code&gt;str&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, and so on&lt;/a&gt;. Consider the following three functions:&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;greeters.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;say_hello&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&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;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello &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;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;be_awesome&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&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;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Yo &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;, together we&#x27;re the awesomest!&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;greet_bob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;greeter_func&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;n&quot;&gt;greeter_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Bob&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.827db10c169f.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.827db10c169f.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;Here, &lt;code&gt;say_hello()&lt;/code&gt; and &lt;code&gt;be_awesome()&lt;/code&gt; are regular functions that expect a name given as a string. The &lt;code&gt;greet_bob()&lt;/code&gt; function, however, expects a function as its argument. You can, for example, pass it the &lt;code&gt;say_hello()&lt;/code&gt; or the &lt;code&gt;be_awesome()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;To test your functions, you can run your code in interactive mode. You do this with the &lt;code&gt;-i&lt;/code&gt; flag. For example, if your code is in a file named &lt;code&gt;greeters.py&lt;/code&gt;, then you run &lt;code&gt;python -i greeters.py&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;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.827db10c169f.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;greet_bob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;say_hello&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Hello Bob&#x27;&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;greet_bob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;be_awesome&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Yo Bob, together we&#x27;re the awesomest!&#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.827db10c169f.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.827db10c169f.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;Note that &lt;code&gt;greet_bob(say_hello)&lt;/code&gt; refers to two functions, but in different ways: &lt;code&gt;greet_bob()&lt;/code&gt; and &lt;code&gt;say_hello&lt;/code&gt;. The &lt;code&gt;say_hello&lt;/code&gt; function is named without parentheses. This means that only a reference to the function is passed. The function isn’t executed. The &lt;code&gt;greet_bob()&lt;/code&gt; function, on the other hand, is written with parentheses, so it will be called as usual.&lt;/p&gt;
&lt;p&gt;This is an important distinction that’s crucial for how functions work as first-class objects. A function name without parentheses is a reference to a function, while a function name with trailing parentheses calls the function and refers to its return value.&lt;/p&gt;
&lt;h3 id=&quot;inner-functions&quot;&gt;Inner Functions&lt;a class=&quot;headerlink&quot; href=&quot;#inner-functions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It’s possible to &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;define functions&lt;/a&gt; &lt;em&gt;inside other functions&lt;/em&gt;. Such functions are called &lt;a href=&quot;https://realpython.com/inner-functions-what-are-they-good-for/&quot;&gt;inner functions&lt;/a&gt;. Here’s an example of a function with two inner functions:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/primer-on-python-decorators/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/primer-on-python-decorators/ »&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 #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>How to Write Beautiful Python Code With PEP 8</title>
      <id>https://realpython.com/python-pep8/</id>
      <link href="https://realpython.com/python-pep8/"/>
      <updated>2024-02-07T14:00:00+00:00</updated>
      <summary>Learn how to write high-quality, readable code by using the Python style guidelines laid out in PEP 8. Following these guidelines helps you make a great impression when sharing your work with potential employers and collaborators.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;PEP 8, sometimes spelled PEP8 or PEP-8, is a document that provides guidelines and best practices on &lt;em&gt;how&lt;/em&gt; to write Python code. It was written in 2001 by &lt;a href=&quot;https://en.wikipedia.org/wiki/Guido_van_Rossum&quot;&gt;Guido van Rossum&lt;/a&gt;, &lt;a href=&quot;https://barry.warsaw.us/&quot;&gt;Barry Warsaw&lt;/a&gt;, and &lt;a href=&quot;https://github.com/ncoghlan&quot;&gt;Alyssa Coghlan&lt;/a&gt;. The primary focus of PEP 8 is to improve the &lt;strong&gt;readability&lt;/strong&gt; and &lt;strong&gt;consistency&lt;/strong&gt; of Python code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll be able to&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write Python code that &lt;strong&gt;conforms to PEP 8&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Understand the reasoning&lt;/strong&gt; behind the guidelines laid out in PEP 8&lt;/li&gt;
&lt;li&gt;Set up your development environment so that you can &lt;strong&gt;start writing PEP 8 compliant Python code&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;PEP stands for &lt;strong&gt;Python Enhancement Proposal&lt;/strong&gt;, and there are &lt;a href=&quot;https://peps.python.org/&quot;&gt;many PEPs&lt;/a&gt;. These documents primarily describe new features proposed for the Python language, but some PEPs also focus on design and style and aim to serve as a resource for the community. PEP 8 is one of these style-focused PEPs.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll cover the key guidelines laid out in PEP 8. You’ll explore beginner to intermediate programming topics. You can learn about more advanced topics by reading the full &lt;a href=&quot;https://www.python.org/dev/peps/pep-0008/&quot;&gt;PEP 8&lt;/a&gt; documentation.&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-pep8-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-pep8-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 write PEP 8 compliant code.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;why-we-need-pep-8&quot;&gt;Why We Need PEP 8&lt;a class=&quot;headerlink&quot; href=&quot;#why-we-need-pep-8&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;“Readability counts.”&lt;/p&gt;
&lt;p&gt;— The Zen of Python&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;PEP 8 exists to improve the readability of Python code. But why is readability so important? Why is writing readable code one of the guiding principles of the Python language, according to the &lt;a href=&quot;https://realpython.com/zen-of-python/&quot;&gt;Zen of Python&lt;/a&gt;?&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 encounter the term &lt;em&gt;Pythonic&lt;/em&gt; when the Python community refers to code that follows the idiomatic writing style specific to Python. &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;Pythonic code&lt;/a&gt; adheres to Python’s design principles and philosophy and emphasizes readability, simplicity, and clarity.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;As Guido van Rossum said, “Code is read much more often than it’s written.” You may spend a few minutes, or a whole day, writing a piece of code to process user authentication. Once you’ve written it, you’re never going to write it again.&lt;/p&gt;
&lt;p&gt;But you’ll definitely have to read it again. That piece of code might remain part of a project you’re working on. Every time you go back to that file, you’ll have to remember what that code does and why you wrote it, so readability matters.&lt;/p&gt;
&lt;p&gt;It can be difficult to remember what a piece of code does a few days, or weeks, after you wrote it.&lt;/p&gt;
&lt;p&gt;If you follow PEP 8, you can be sure that you’ve &lt;a href=&quot;#naming-conventions&quot;&gt;named&lt;/a&gt; your &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; well. You’ll know that you’ve added &lt;a href=&quot;#whitespace-in-expressions-and-statements&quot;&gt;enough whitespace&lt;/a&gt; so it’s easier to follow logical steps in your code. You’ll also have &lt;a href=&quot;#comments&quot;&gt;commented&lt;/a&gt; your code well. All of this will mean your code is more readable and easier to come back to. If you’re a beginner, following the rules of PEP 8 can make learning Python a much more pleasant task.&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; Following PEP 8 is particularly important if you’re looking for a development job. Writing clear, readable code shows professionalism. It’ll tell an employer that you understand how to structure your code well.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you have more experience writing Python code, then you may need to collaborate with others. Writing readable code here is crucial. Other people, who may have never met you or seen your coding style before, will have to read and understand your code. Having guidelines that you follow and recognize will make it  easier for others to read your code.&lt;/p&gt;
&lt;h2 id=&quot;naming-conventions&quot;&gt;Naming Conventions&lt;a class=&quot;headerlink&quot; href=&quot;#naming-conventions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;“Explicit is better than implicit.”&lt;/p&gt;
&lt;p&gt;— The Zen of Python&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When you write Python code, you have to name a lot of things: variables, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&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/pypi-publish-python-package/&quot;&gt;packages&lt;/a&gt;, and so on. Choosing sensible names will save you time and energy later. You’ll be able to figure out, from the name, what a certain variable, function, or class represents. You’ll also avoid using potentially confusing names that might result in errors that are difficult to debug.&lt;/p&gt;
&lt;p&gt;One suggestion is to never use &lt;code&gt;l&lt;/code&gt;, &lt;code&gt;O&lt;/code&gt;, or &lt;code&gt;I&lt;/code&gt; single letter names as these can be mistaken for &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;, depending on what &lt;a href=&quot;https://realpython.com/coding-font/&quot;&gt;typeface&lt;/a&gt; a programmer uses.&lt;/p&gt;
&lt;p&gt;For example, consider the code below, where you assign the value &lt;code&gt;2&lt;/code&gt; to the single letter &lt;code&gt;O&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;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;n&quot;&gt;O&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# ❌ Not recommended&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.827db10c169f.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.827db10c169f.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;Doing this may look like you’re trying to reassign &lt;code&gt;2&lt;/code&gt; to zero. While making such a reassignment isn’t possible in Python and will cause a &lt;a href=&quot;https://realpython.com/python-exceptions/&quot;&gt;syntax error&lt;/a&gt;, using an ambigious variable name such as &lt;code&gt;O&lt;/code&gt; can make your code more confusing and harder to read and reason about.&lt;/p&gt;
&lt;h3 id=&quot;naming-styles&quot;&gt;Naming Styles&lt;a class=&quot;headerlink&quot; href=&quot;#naming-styles&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The table below outlines some of the common naming styles in Python code and when you should use them: &lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-pep8/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-pep8/ »&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: 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>Python News: What&#x27;s New From January 2024</title>
      <id>https://realpython.com/python-news-january-2024/</id>
      <link href="https://realpython.com/python-news-january-2024/"/>
      <updated>2024-02-05T14:00:00+00:00</updated>
      <summary>In January 2024, Python 3.13.0a3 was released. A new JIT compiler was added to Python 3.13. The Python Software Foundation announced new developers in residence, and the Python ecosystem released new versions of projects, such as Django and pandas.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In January 2024, Python &lt;strong&gt;3.13.0a3&lt;/strong&gt; was released! With several exciting features, improvements, and optimizations, this release is the third of six planned alpha releases. During the alpha phase, features may be added up until the start of the beta phase on May 7. This is a &lt;a href=&quot;https://realpython.com/python-pre-release/&quot;&gt;pre-release&lt;/a&gt;, and you shouldn’t use it for production environments. However, it’s a great way to try out some new and exciting language features.&lt;/p&gt;
&lt;p&gt;The steering council had its elections last December, and the Python Software Foundation made a few cool announcements, including the announcement of a new developer in residence.&lt;/p&gt;
&lt;p&gt;There is also exciting news regarding Python conferences, such as PyCon US 2024 and DjangoCon Europe 2024.&lt;/p&gt;
&lt;p&gt;Let’s dive into the most exciting &lt;strong&gt;Python news&lt;/strong&gt; from January 2024!&lt;/p&gt;
&lt;h2 id=&quot;python-3130-alpha-3-arrives&quot;&gt;Python 3.13.0 Alpha 3 Arrives&lt;a class=&quot;headerlink&quot; href=&quot;#python-3130-alpha-3-arrives&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This January, Python &lt;a href=&quot;https://pythoninsider.blogspot.com/2024/01/python-3130-alpha-3-is-now-available.html&quot;&gt;released&lt;/a&gt; its third &lt;strong&gt;alpha preview release&lt;/strong&gt;, 3.13.0a3. This version is the third of six planned alpha releases. During the alpha phase, Python will receive new features up until the start of the &lt;strong&gt;beta phase&lt;/strong&gt; on May 7. Alpha releases make it easier to test the current state of new features and bug fixes and to test the release process.&lt;/p&gt;
&lt;p&gt;Many new features for Python 3.13 are still being planned. The primary efforts surround two core areas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Removing the global interpreter lock, or GIL (&lt;a href=&quot;https://peps.python.org/pep-0703/&quot;&gt;PEP 703&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Improving Python performance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So far, some of the most notable changes include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Colorized &lt;a href=&quot;https://docs.python.org/dev/whatsnew/3.13.html#improved-error-messages&quot;&gt;exception tracebacks&lt;/a&gt; by default in the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Stripped &lt;a href=&quot;https://docs.python.org/dev/whatsnew/3.13.html#other-language-changes&quot;&gt;leading indentation&lt;/a&gt; in &lt;a href=&quot;https://realpython.com/documenting-python-code/&quot;&gt;docstrings&lt;/a&gt;, which reduces memory use and the size of &lt;code&gt;.pyc&lt;/code&gt; files&lt;/li&gt;
&lt;li&gt;Scheduled removals of deprecated modules: &lt;code&gt;aifc&lt;/code&gt;, &lt;code&gt;audioop&lt;/code&gt;, &lt;code&gt;chunk&lt;/code&gt;, &lt;code&gt;cgi&lt;/code&gt;, &lt;code&gt;cgitb&lt;/code&gt;, &lt;code&gt;crypt&lt;/code&gt;, &lt;code&gt;imghdr&lt;/code&gt;, &lt;code&gt;mailcap&lt;/code&gt;, &lt;code&gt;msilib&lt;/code&gt;, &lt;code&gt;nis&lt;/code&gt;, &lt;code&gt;nntplib&lt;/code&gt;, &lt;code&gt;ossaudiodev&lt;/code&gt;, &lt;code&gt;pipes&lt;/code&gt;, &lt;code&gt;sndhdr&lt;/code&gt;, &lt;code&gt;spwd&lt;/code&gt;, &lt;code&gt;sunau&lt;/code&gt;, &lt;code&gt;telnetlib&lt;/code&gt;, &lt;code&gt;uu&lt;/code&gt;, &lt;code&gt;xdrlib&lt;/code&gt;, and &lt;code&gt;lib2to3&lt;/code&gt; (&lt;a href=&quot;https://peps.python.org/pep-0594/&quot;&gt;PEP 594&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/dev/whatsnew/3.13.html#removed&quot;&gt;Many other removals&lt;/a&gt; of deprecated classes, functions, and methods in various standard-library modules&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As usual, this version also brings several deprecations that you may need to consider. For a detailed list of changes, additions, and removals, you can check the &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/changelog.html#python-3-12-0-release-candidate-1&quot;&gt;changelog&lt;/a&gt;. The next pre-release of Python 3.13 will be 3.13.0a4, which is currently scheduled for February 13.&lt;/p&gt;
&lt;h2 id=&quot;jit-just-in-time-compiler-available-on-python-313&quot;&gt;JIT (Just-in-Time) Compiler Available on Python 3.13&lt;a class=&quot;headerlink&quot; href=&quot;#jit-just-in-time-compiler-available-on-python-313&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In late December 2023, CPython core developer &lt;a href=&quot;https://github.com/brandtbucher&quot;&gt;Brandt Bucher&lt;/a&gt; pushed a &lt;a href=&quot;https://github.com/python/cpython/pull/113465&quot;&gt;pull request&lt;/a&gt; to the Python 3.13 branch adding a JIT (just-in-time) compiler. This pull request responds to issue &lt;a href=&quot;https://github.com/python/cpython/issues/113464&quot;&gt;#113464&lt;/a&gt; JIT Compilation, which is intended to add &lt;a href=&quot;https://en.wikipedia.org/wiki/Just-in-time_compilation&quot;&gt;just-in-time compilation&lt;/a&gt; to CPython 3.13.0.&lt;/p&gt;
&lt;p&gt;JIT compilation consists of compiling the code during the execution of a program rather than before execution. It’s an on-demand compilation.&lt;/p&gt;
&lt;p&gt;Real Python contributor &lt;a href=&quot;https://realpython.com/team/ashaw/&quot;&gt;Anthony Shaw&lt;/a&gt; has written a great post about this new &lt;a href=&quot;https://tonybaloney.github.io/posts/python-gets-a-jit.html&quot;&gt;JIT compiler in Python 3.13&lt;/a&gt;. In his article, he talks about JIT compilers and different types of them.&lt;/p&gt;
&lt;p&gt;The most exciting result of having this JIT compiler in Python 3.13 is that initial benchmarks show that Python’s performance will improve by &lt;a href=&quot;https://github.com/python/cpython/pull/113465#issuecomment-1876225775&quot;&gt;2 to 9 percent&lt;/a&gt;! This may seem like a small improvement, but as Anthony Shaw says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Think of this JIT as being the cornerstone of a series of much larger optimizations. None of which are possible without it. (&lt;a href=&quot;https://tonybaloney.github.io/posts/python-gets-a-jit.html&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-january-2024/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-january-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 #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>Python&#x27;s Format Mini-Language for Tidy Strings</title>
      <id>https://realpython.com/python-format-mini-language/</id>
      <link href="https://realpython.com/python-format-mini-language/"/>
      <updated>2024-01-31T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about Python&#x27;s format mini-language. You&#x27;ll learn how to use the mini-language to create working format specifiers and build nicely formatted strings and messages in your code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you’re doing &lt;a href=&quot;https://realpython.com/python-f-strings/#interpolating-and-formatting-strings-before-python-36&quot;&gt;string interpolation&lt;/a&gt; in your Python code, you often need to format the interpolated values to meet some formatting requirements. To do this, Python provides what is known as the &lt;strong&gt;format mini-language&lt;/strong&gt;, which defines the syntax of a &lt;strong&gt;format specifier&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Perhaps you’re comfortable working with strings, but you want to take even more control of them. With proficiency in the format mini-language, you’ll be able to use format specifiers to do things like formatting numbers as currency values, using scientific notation, expressing a value as a percentage, and so much more.&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;Learn the &lt;strong&gt;format mini-language syntax&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Align&lt;/strong&gt; and &lt;strong&gt;fill&lt;/strong&gt; textual output in your code&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Convert&lt;/strong&gt; between data &lt;strong&gt;types&lt;/strong&gt; in your outputs&lt;/li&gt;
&lt;li&gt;Provide &lt;strong&gt;format fields&lt;/strong&gt; dynamically&lt;/li&gt;
&lt;li&gt;Format &lt;strong&gt;numeric values&lt;/strong&gt; in different ways&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with Python’s string interpolation tools, such as the &lt;a href=&quot;https://realpython.com/python-formatted-output/#the-python-string-format-method&quot;&gt;&lt;code&gt;str.format()&lt;/code&gt;&lt;/a&gt; method and &lt;a href=&quot;https://realpython.com/python-f-strings/&quot;&gt;f-strings&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/python-format-mini-language-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-format-mini-language-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 format mini-language for strings.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;using-string-interpolation-and-replacement-fields&quot;&gt;Using String Interpolation and Replacement Fields&lt;a class=&quot;headerlink&quot; href=&quot;#using-string-interpolation-and-replacement-fields&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you’re working with strings, it’s common that you need to embed or insert values and objects into your strings so that you can build new strings dynamically. This task is commonly known as &lt;strong&gt;string interpolation&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In Python, you’ll find three popular tools that allow you to perform string interpolation:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &lt;a href=&quot;https://realpython.com/python-modulo-string-formatting/&quot;&gt;modulo operator (&lt;code&gt;%&lt;/code&gt;)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://realpython.com/python-f-strings/#the-strformat-method&quot;&gt;&lt;code&gt;str.format()&lt;/code&gt; method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-f-strings/#formatting-strings-with-pythons-f-string&quot;&gt;F-string literals&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The modulo operator is sort of an old-fashioned tool. It was the first string interpolation tool in Python. Unfortunately, it doesn’t provide many string formatting features. So, in this tutorial, you’ll focus on the &lt;code&gt;str.format()&lt;/code&gt; method and f-strings.&lt;/p&gt;
&lt;p&gt;To dynamically interpolate a value into a string, you need something called &lt;strong&gt;replacement fields&lt;/strong&gt;. In both &lt;code&gt;str.format()&lt;/code&gt; and f-strings, curly braces (&lt;code&gt;{}&lt;/code&gt;) delimit replacement fields. Inside these braces, you can put a variable, expression, or any object. When you run the code, Python replaces the field with the actual value.&lt;/p&gt;
&lt;p&gt;Anything not contained in braces is considered literal text, and Python copies it unchanged to the output.&lt;/p&gt;
&lt;p&gt;In the following sections, you’ll learn how replacement fields work in &lt;code&gt;str.format()&lt;/code&gt; and f-strings.&lt;/p&gt;
&lt;h3 id=&quot;the-strformat-method&quot;&gt;The &lt;code&gt;str.format()&lt;/code&gt; Method&lt;a class=&quot;headerlink&quot; href=&quot;#the-strformat-method&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can use &lt;code&gt;str.format()&lt;/code&gt; to interpolate values into your strings. This method operates on a string object where you insert replacement fields as needed. Then Python interpolates the arguments to &lt;code&gt;.format()&lt;/code&gt; into the string to build the final string dynamically:&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.827db10c169f.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;s2&quot;&gt;&quot;Hello, &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;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Pythonista&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Hello, Pythonista!&#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.827db10c169f.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.827db10c169f.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, you have a string containing a replacement field. Then, you call &lt;code&gt;.format()&lt;/code&gt; with a single argument. When you run this code, the method inserts its argument into the replacement field and builds a final string.&lt;/p&gt;
&lt;p&gt;You can use &lt;code&gt;.format()&lt;/code&gt; in several ways. In the example above, the replacement field is empty. However, you can use zero-based indices to define a specific insertion order. You can also use named fields:&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.827db10c169f.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;s2&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{0}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;! Good &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{1}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Pythonista&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;morning&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Hello, Pythonista! Good morning!&#x27;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{name}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;! Good &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{moment}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&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;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Pythonista&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;moment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;morning&quot;&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;go&quot;&gt;&#x27;Hello, Pythonista! Good morning!&#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.827db10c169f.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.827db10c169f.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 the first example, you use integer indices to define the order in which you want to insert each argument into the replacement fields. In the second example, you use explicit argument names to insert the values into the final string.&lt;/p&gt;
&lt;p&gt;The Python documentation uses the following &lt;a href=&quot;https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form&quot;&gt;Backus–Naur form (BNF) notation&lt;/a&gt; to define the syntax of a replacement field for the &lt;code&gt;.format()&lt;/code&gt; method:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;abnf&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;BNF Grammar&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;replacement_&lt;span class=&quot;nc&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;::&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;l&quot;&gt;&quot;{&quot;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;field_&lt;span class=&quot;nc&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;l&quot;&gt;&quot;!&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;conversion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;l&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;format_&lt;span class=&quot;nc&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                       &lt;/span&gt;&lt;span class=&quot;l&quot;&gt;&quot;}&quot;&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.827db10c169f.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.827db10c169f.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;From this BNF rule, you can conclude that the field name is optional. After that, you can use an exclamation mark (&lt;code&gt;!&lt;/code&gt;) to provide a quick &lt;code&gt;conversion&lt;/code&gt; field. This field can take one of the following forms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;!s&lt;/code&gt; calls &lt;a href=&quot;https://docs.python.org/3/library/functions.html?highlight=built#func-str&quot;&gt;&lt;code&gt;str()&lt;/code&gt;&lt;/a&gt; on the argument.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;!r&lt;/code&gt; calls &lt;a href=&quot;https://docs.python.org/3/library/functions.html?highlight=built#repr&quot;&gt;&lt;code&gt;repr()&lt;/code&gt;&lt;/a&gt; on the argument.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;!a&lt;/code&gt; calls &lt;a href=&quot;https://docs.python.org/3/library/functions.html?highlight=built#ascii&quot;&gt;&lt;code&gt;ascii()&lt;/code&gt;&lt;/a&gt; on the argument.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-format-mini-language/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-format-mini-language/ »&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>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>Python Exceptions: An Introduction</title>
      <id>https://realpython.com/python-exceptions/</id>
      <link href="https://realpython.com/python-exceptions/"/>
      <updated>2024-01-29T14:00:00+00:00</updated>
      <summary>In this beginner tutorial, you&#x27;ll learn what exceptions are good for in Python. You&#x27;ll see how to raise exceptions and how to handle them with try ... except blocks.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;A Python program terminates as soon as it encounters an error. In Python, an error can be a syntax error or an exception. In this tutorial, you’ll see what an exception is and how it differs from a syntax error. After that, you’ll learn about raising exceptions and making assertions. Then, you’ll get to know all the exception-related keywords that you can use in a &lt;code&gt;try&lt;/code&gt; … &lt;code&gt;except&lt;/code&gt; block to fine-tune how you can work with Python exceptions.&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;Raise an exception&lt;/strong&gt; in Python with &lt;code&gt;raise&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Debug and test&lt;/strong&gt; your code with &lt;code&gt;assert&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Handle exceptions&lt;/strong&gt; with &lt;code&gt;try&lt;/code&gt; and &lt;code&gt;except&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fine-tune your exception handling&lt;/strong&gt; with &lt;code&gt;else&lt;/code&gt; and &lt;code&gt;finally&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll get to know these keywords by walking through a practical example of handling a platform-related exception. Finally, you’ll also learn how to create your own custom Python exceptions.&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-exceptions-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-exceptions-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 exceptions work in Python.&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.827db10c169f.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 “Python Exceptions: An Introduction” 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-exceptions/&quot; target=&quot;_blank&quot;&gt;Take the Quiz »&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;understanding-exceptions-and-syntax-errors&quot;&gt;Understanding Exceptions and Syntax Errors&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-exceptions-and-syntax-errors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://realpython.com/invalid-syntax-python/&quot;&gt;Syntax errors&lt;/a&gt; occur when the parser detects an incorrect statement. Observe the following example:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pytb&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 Traceback&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;x&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print(0 / 0))&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;w&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;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;pm&quot;&gt;^&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;SyntaxError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;unmatched &#x27;)&#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.827db10c169f.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.827db10c169f.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 arrow indicates where the parser ran into the &lt;strong&gt;syntax error&lt;/strong&gt;. Additionally, the error message gives you a hint about what went wrong. In this example, there was one bracket too many. Remove it and run your code again:&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.827db10c169f.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;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;, in &lt;span class=&quot;n&quot;&gt;&amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;ZeroDivisionError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;division by zero&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.827db10c169f.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.827db10c169f.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 time, you ran into an &lt;strong&gt;exception error&lt;/strong&gt;. This type of error occurs whenever syntactically correct Python code results in an error. The last line of the message indicates what type of exception error you ran into.&lt;/p&gt;
&lt;p&gt;Instead of just writing &lt;em&gt;exception error&lt;/em&gt;, Python details what &lt;em&gt;type&lt;/em&gt; of exception error it encountered. In this case, it was a &lt;code&gt;ZeroDivisionError&lt;/code&gt;. Python comes with &lt;a href=&quot;https://docs.python.org/3/library/exceptions.html&quot;&gt;various built-in exceptions&lt;/a&gt; as well as the possibility to create user-defined exceptions.&lt;/p&gt;
&lt;h2 id=&quot;raising-an-exception-in-python&quot;&gt;Raising an Exception in Python&lt;a class=&quot;headerlink&quot; href=&quot;#raising-an-exception-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are scenarios where you might want to stop your program by raising an exception if a condition occurs. You can do this with the &lt;a href=&quot;https://realpython.com/python-raise-exception/&quot;&gt;&lt;code&gt;raise&lt;/code&gt;&lt;/a&gt; keyword:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/raise.3931e8819e08.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/raise.3931e8819e08.png&quot; width=&quot;1394&quot; height=&quot;311&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/raise.3931e8819e08.png&amp;amp;w=348&amp;amp;sig=fe4872f24f9121ecf0f4dbdba805c754f0fd42cf 348w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/raise.3931e8819e08.png&amp;amp;w=464&amp;amp;sig=dc5fd94d9614729105d5285574d5b4755ee1454a 464w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/raise.3931e8819e08.png&amp;amp;w=697&amp;amp;sig=8f2b5e3f414c44ff5f7464e4793598843ba71ad1 697w, https://files.realpython.com/media/raise.3931e8819e08.png 1394w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Illustration of  raise statement usage&quot; data-asset=&quot;394&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;You can even complement the statement with a custom message. Assume that you’re writing a tiny toy program that expects only numbers up to &lt;code&gt;5&lt;/code&gt;. You can raise an error when an unwanted condition occurs:&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;low.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;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;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;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;Exception&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;The number should not exceed 5. (&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&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;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&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.827db10c169f.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.827db10c169f.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, you raised an &lt;code&gt;Exception&lt;/code&gt; object and passed it an informative custom message. You built the message using an &lt;a href=&quot;https://realpython.com/python-f-strings/&quot;&gt;f-string&lt;/a&gt; and a &lt;a href=&quot;https://realpython.com/python-f-strings/#self-documenting-expressions-for-debugging&quot;&gt;self-documenting expression&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you run &lt;code&gt;low.py&lt;/code&gt;, you’ll get the following output:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pytb&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 Traceback&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;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;./low.py&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;, in &lt;span class=&quot;n&quot;&gt;&amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;Exception&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;The number should not exceed 5. (&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&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;gr&quot;&gt;Exception&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;The number should not exceed 5. (number=10)&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.827db10c169f.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.827db10c169f.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 program comes to a halt and displays the exception to your &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt;, offering you helpful clues about what went wrong. Note that the final call to &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; never executed, because Python raised the exception before it got to that line of code.&lt;/p&gt;
&lt;p&gt;With the &lt;code&gt;raise&lt;/code&gt; keyword, you can raise any exception object in Python and stop your program when an unwanted condition occurs.&lt;/p&gt;
&lt;h2 id=&quot;debugging-during-development-with-assert&quot;&gt;Debugging During Development With &lt;code&gt;assert&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#debugging-during-development-with-assert&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before moving on to the most common way of working with exceptions in Python using &lt;a href=&quot;https://realpython.com/python-exceptions/#handling-exceptions-with-the-try-and-except-block&quot;&gt;the &lt;code&gt;try&lt;/code&gt; … &lt;code&gt;except&lt;/code&gt; block&lt;/a&gt;, you’ll take a quick look at an exception that’s a bit different than the others.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-exceptions/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-exceptions/ »&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 #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>
  
    <entry>
      <title>The Real Python Podcast – Episode #187: Serializing Data With Python &amp; Underscore Naming Conventions</title>
      <id>https://realpython.com/podcasts/rpp/187/</id>
      <link href="https://realpython.com/podcasts/rpp/187/"/>
      <updated>2024-01-12T12:00:00+00:00</updated>
      <summary>Do you need to transfer an extensive data collection for a science project? What&#x27;s the best way to send executable code over the wire for distributed processing? What are the different ways to serialize data in Python? 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;Do you need to transfer an extensive data collection for a science project? What&#x27;s the best way to send executable code over the wire for distributed processing? What are the different ways to serialize data in Python? 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 Exercises: Functions and Loops</title>
      <id>https://realpython.com/courses/python-exercises-functions-loops/</id>
      <link href="https://realpython.com/courses/python-exercises-functions-loops/"/>
      <updated>2024-01-09T14:00:00+00:00</updated>
      <summary>In this Python Basics Exercises course, you&#x27;ll practice creating user-defined functions that you can execute multiple times in your code. Additionally, you&#x27;ll gain experience in repeating code using for and while loops.</summary>
      <content type="html">
        &lt;p&gt;As you learned in &lt;a href=&quot;https://realpython.com/courses/python-basics-functions-loops/&quot;&gt;Python Basics: Functions and Loops&lt;/a&gt;, functions serve as the fundamental building blocks in almost every Python program. They&amp;rsquo;re where the real action happens!&lt;/p&gt;
&lt;p&gt;You now know that functions are crucial for breaking down code into smaller, manageable chunks. They enable you to define actions that your program can execute repeatedly throughout your code. Instead of duplicating the same code whenever your program needs to accomplish a particular task, you can simply call the function.&lt;/p&gt;
&lt;p&gt;However, there are instances when you need to repeat certain code multiple times in a row. This is where loops become invaluable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this Python Basics Exercises video course, you&amp;rsquo;ll practice:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Creating &lt;strong&gt;user-defined functions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implementing &lt;strong&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Getting &lt;strong&gt;user input&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rounding&lt;/strong&gt; numbers&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>The Real Python Podcast – Episode #186: Exploring Python in Excel</title>
      <id>https://realpython.com/podcasts/rpp/186/</id>
      <link href="https://realpython.com/podcasts/rpp/186/"/>
      <updated>2024-01-05T12:00:00+00:00</updated>
      <summary>Are you interested in using your Python skills within Excel? Would you like to share a data science project or visualization as a single Office file? This week on the show, we speak with Principal Architect John Lam and Sr. Cloud Developer Advocate Sarah Kaiser from Microsoft about Python in Excel.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in using your Python skills within Excel? Would you like to share a data science project or visualization as a single Office file? This week on the show, we speak with Principal Architect John Lam and Sr. Cloud Developer Advocate Sarah Kaiser from Microsoft about Python in Excel.&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>HTTP Requests With Python&#x27;s urllib.request</title>
      <id>https://realpython.com/courses/python-urllib-request/</id>
      <link href="https://realpython.com/courses/python-urllib-request/"/>
      <updated>2024-01-02T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll explore how to make HTTP requests using Python&#x27;s handy built-in module, urllib.request. You&#x27;ll try out examples and go over common errors, all while learning more about HTTP requests and Python in general.</summary>
      <content type="html">
        &lt;p&gt;If you need to perform HTTP requests using Python, then the widely used &lt;a href=&quot;https://docs.python-requests.org/en/latest/&quot;&gt;Requests&lt;/a&gt; library is often the way to go. However, if you prefer to use only standard-library Python and minimize dependencies, then you can turn to &lt;code&gt;urllib.request&lt;/code&gt; instead.&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;Learn the essentials of making basic &lt;a href=&quot;https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_and_response_messages_through_connections&quot;&gt;HTTP requests&lt;/a&gt; with &lt;code&gt;urllib.request&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Explore the inner workings of an &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages&quot;&gt;HTTP message&lt;/a&gt; and how &lt;code&gt;urllib.request&lt;/code&gt; represents it&lt;/li&gt;
&lt;li&gt;Grasp the concept of handling &lt;strong&gt;character encodings&lt;/strong&gt; in HTTP messages&lt;/li&gt;
&lt;li&gt;Understand common hiccups when using &lt;code&gt;urllib.request&lt;/code&gt; and learn how to resolve them&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;re already familiar with HTTP requests such as &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET&quot;&gt;GET&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST&quot;&gt;POST&lt;/a&gt;, then you&amp;rsquo;re well prepared for this video course. Additionally, you should have prior experience using Python to &lt;a href=&quot;https://realpython.com/read-write-files-python/&quot;&gt;read and write files&lt;/a&gt;, ideally using a &lt;a href=&quot;https://realpython.com/python-with-statement/&quot;&gt;context manager&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the end, you&amp;rsquo;ll discover that making HTTP requests doesn&amp;rsquo;t have to be a frustrating experience, despite its reputation. Many of the challenges people face in this process stem from the inherent complexity of the Internet. The good news is that the &lt;code&gt;urllib.request&lt;/code&gt; module can help demystify much of this complexity.&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 #185: 2023 Real Python Tutorial &amp; Video Course Wrap-Up</title>
      <id>https://realpython.com/podcasts/rpp/185/</id>
      <link href="https://realpython.com/podcasts/rpp/185/"/>
      <updated>2023-12-29T12:00:00+00:00</updated>
      <summary>Three members of the Real Python team are joining us this week: Kate Finegan, Tappan Moore, and Philipp Acsany. We wanted to share a year-end wrap-up with tutorials, step-by-step projects, code conversations, and video courses that showcase what our team created this year.</summary>
      <content type="html">
        &lt;p&gt;Three members of the Real Python team are joining us this week: Kate Finegan, Tappan Moore, and Philipp Acsany. We wanted to share a year-end wrap-up with tutorials, step-by-step projects, code conversations, and video courses that showcase what our team created this year.&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 #184: PyCoder&#x27;s Weekly 2023 Wrap Up</title>
      <id>https://realpython.com/podcasts/rpp/184/</id>
      <link href="https://realpython.com/podcasts/rpp/184/"/>
      <updated>2023-12-22T12:00:00+00:00</updated>
      <summary>It&#x27;s been a fascinating year for the Python language and community. PyCoder&#x27;s Weekly included over 1,500 links to articles, blog posts, tutorials, and projects in 2023. Christopher Trudeau is back on the show this week to help wrap up everything by sharing some highlights and Python trends from across the year.</summary>
      <content type="html">
        &lt;p&gt;It&#x27;s been a fascinating year for the Python language and community. PyCoder&#x27;s Weekly included over 1,500 links to articles, blog posts, tutorials, and projects in 2023. Christopher Trudeau is back on the show this week to help wrap up everything by sharing some highlights and Python trends from across the year.&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: Reading and Writing Files</title>
      <id>https://realpython.com/courses/python-exercises-reading-writing-files/</id>
      <link href="https://realpython.com/courses/python-exercises-reading-writing-files/"/>
      <updated>2023-12-19T14:00:00+00:00</updated>
      <summary>In this video tutorial, you&#x27;ll practice transferring data between your Python programs and external software by reading and writing files. Through exercises, you&#x27;ll master the art of reading and writing information saved in CSV file format, which is extensively used for exchanging tabular data.</summary>
      <content type="html">
        &lt;p&gt;Files play a key role in computing, as they store and transfer data. You likely come across numerous files on a daily basis. In &lt;a href=&quot;https://realpython.com/courses/python-reading-and-writing-files/&quot;&gt;Python Basics: Reading and Writing Files&lt;/a&gt;, you dove into the world of file manipulation using Python.&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;Differentiating between &lt;strong&gt;text&lt;/strong&gt; and &lt;strong&gt;binary&lt;/strong&gt; files&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;character encodings&lt;/strong&gt; and &lt;strong&gt;line endings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Manipulating &lt;strong&gt;file objects&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Reading and writing character data with different &lt;strong&gt;file modes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;open()&lt;/code&gt;, &lt;code&gt;Path.open()&lt;/code&gt;, and the &lt;code&gt;with&lt;/code&gt; statement&lt;/li&gt;
&lt;li&gt;Leveraging the &lt;code&gt;csv&lt;/code&gt; module to manipulate &lt;strong&gt;CSV data&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is part of the Python Basics series, which is complements the book &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;. Additionally, you can explore 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;Please note that throughout this course, 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;. If you&amp;rsquo;re new to Python, then you might want to check out &lt;a href=&quot;https://realpython.com/courses/setting-up-python/&quot;&gt;Python Basics: Setting Up Python&lt;/a&gt; before diving into 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>
  

</feed>
