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

  
    <entry>
      <title>Using the bpython Enhanced REPL</title>
      <id>https://realpython.com/courses/using-bpython-enhanced-repl/</id>
      <link href="https://realpython.com/courses/using-bpython-enhanced-repl/"/>
      <updated>2023-10-31T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about bpython, an alternative Python REPL that brings code suggestions and many other IDE-like features to the terminal. Once you discover how much bpython can improve your productivity, you&#x27;ll never want to return to using the vanilla Python REPL again.</summary>
      <content type="html">
        &lt;p&gt;The standard Python interpreter lets you &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run scripts&lt;/a&gt; from files or &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interactively execute code&lt;/a&gt; on the fly in a so-called &lt;strong&gt;read-evaluate-print loop (REPL)&lt;/strong&gt;. While this is a powerful tool for exploring the language and discovering its libraries through instant feedback on your code inputs, the default REPL shipped with Python has several limitations. Luckily, alternatives like &lt;strong&gt;bpython&lt;/strong&gt; offer a much more programmer-friendly and convenient experience.&lt;/p&gt;
&lt;p&gt;You can use bpython to experiment with your code or quickly test an idea without switching contexts between different programs, just like in an &lt;strong&gt;integrated development environment (IDE)&lt;/strong&gt;. In addition, bpython may be a valuable teaching tool in either a virtual or physical classroom.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install and use bpython as your &lt;strong&gt;alternative Python REPL&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Boost your &lt;strong&gt;productivity&lt;/strong&gt; thanks to bpython&amp;rsquo;s unique features&lt;/li&gt;
&lt;li&gt;Tweak bpython&amp;rsquo;s &lt;strong&gt;configuration&lt;/strong&gt; and its &lt;strong&gt;color theme&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use common &lt;strong&gt;keyboard shortcuts&lt;/strong&gt; to code more quickly&lt;/li&gt;
&lt;li&gt;Contribute to bpython&amp;rsquo;s &lt;strong&gt;open-source&lt;/strong&gt; project on GitHub&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before starting this course, make sure you&amp;rsquo;re already familiar with &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;Python basics&lt;/a&gt; and know how to start the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;standard Python REPL&lt;/a&gt; in the command line. In addition, you should be able to &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;install packages with &lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;, ideally into a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt;.&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 Use Type Hints for Multiple Return Types in Python</title>
      <id>https://realpython.com/python-type-hints-multiple-types/</id>
      <link href="https://realpython.com/python-type-hints-multiple-types/"/>
      <updated>2023-10-30T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn to specify multiple return types using type hints in Python. You&#x27;ll cover working with one or several pieces of data, defining type aliases, and type checking with a third-party static type checker tool.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In Python, &lt;strong&gt;type hinting&lt;/strong&gt; is an optional yet useful feature to make your code easier to read, reason about, and debug. With type hints, you let other developers know the expected data types for variables, function arguments, and return values. As you write code for applications that require greater flexibility, you may need to specify &lt;strong&gt;multiple return types&lt;/strong&gt; to make your code more robust and adaptable to different situations.&lt;/p&gt;
&lt;p&gt;You’ll encounter different use cases where you may want to annotate multiple return types within a single function in Python. In other words, the data returned can vary in type. In this tutorial, you’ll walk through examples of how to specify multiple return types for a function that parses a string from an email address to grab the domain name.&lt;/p&gt;
&lt;p&gt;In addition, you’ll see examples of how to specify type hints for callback functions or functions that take another function as input. With these examples, you’ll be ready to express type hints in functional programming.&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; Typically, you want to work with functions that are generous in which type of arguments they accept, while they’re specific about the type of their return value. For example, a function may accept any iterable like a list, tuple, or generator, but always return a list.&lt;/p&gt;
&lt;p&gt;If your function can return several different types, then you should first consider whether you can &lt;a href=&quot;https://realpython.com/python-refactoring/&quot;&gt;refactor&lt;/a&gt; it to have a single return type. In this tutorial, you’ll learn how to deal with those functions that need multiple return types.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To get the most out of this tutorial, you should know the basics of what &lt;a href=&quot;https://realpython.com/python-type-checking/&quot;&gt;type hints&lt;/a&gt; in Python are and how you use them.&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-type-hints-multiple-types-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-type-hints-multiple-types-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to the free sample code&lt;/a&gt; that shows you how to declare type hints for multiple types in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;use-pythons-type-hints-for-one-piece-of-data-of-alternative-types&quot;&gt;Use Python’s Type Hints for One Piece of Data of Alternative Types&lt;a class=&quot;headerlink&quot; href=&quot;#use-pythons-type-hints-for-one-piece-of-data-of-alternative-types&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this section, you’ll learn how to write type hints for functions that can &lt;a href=&quot;https://realpython.com/python-return-statement/&quot;&gt;return&lt;/a&gt; one piece of data that could be of different types. The scenarios for considering multiple return types include:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Conditional statements&lt;/strong&gt;: When a function uses &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional statements&lt;/a&gt; that return different types of results, you can convey this by specifying alternative return types for your function using type hints.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optional values&lt;/strong&gt;: A function may sometimes return no value, in which case you can use type hints to signal the occasional absence of a return value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Error handling&lt;/strong&gt;: When a function encounters an error, you may want to return a specific error object that’s different from the normal results’ return type. Doing so could help other developers handle errors in the code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;: When designing and writing code, you generally want it to be versatile, flexible, and reusable. This could mean writing functions that can handle a range of data types. Specifying this in type hints helps other developers understand your code’s versatility and its intended uses in different cases.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the example below, you use type hints in working with conditional statements. Imagine that you’re processing customer data and want to write a function to parse users’ email addresses to extract their usernames.&lt;/p&gt;
&lt;p&gt;To represent one piece of data of multiple types using type hints in &lt;a href=&quot;https://realpython.com/python310-new-features/&quot;&gt;Python 3.10&lt;/a&gt; or newer, you can use the &lt;strong&gt;pipe operator (&lt;code&gt;|&lt;/code&gt;)&lt;/strong&gt;. Here’s how you’d use type hints in a function that typically returns a string containing the username but can also return &lt;code&gt;None&lt;/code&gt; if the corresponding email address is incomplete:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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 python 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;parse_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;@&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;@&quot;&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;username&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 example above, the &lt;code&gt;parse_email()&lt;/code&gt; function has a conditional statement that checks if the email address passed as an argument contains the at sign (&lt;code&gt;@&lt;/code&gt;). If it does, then the function splits on that symbol to extract the elements before and after the at sign, stores them in local &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt;, and returns the username. If the argument doesn’t contain an at sign, then the return value is &lt;a href=&quot;https://realpython.com/null-in-python/&quot;&gt;&lt;code&gt;None&lt;/code&gt;&lt;/a&gt;, indicating an invalid email address.&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; In practice, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Email_address#Validation_and_verification&quot;&gt;validation rules&lt;/a&gt; for email addresses are much more complicated.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;So, the return value of this function is either a &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;string&lt;/a&gt; containing the username or &lt;code&gt;None&lt;/code&gt; if the email address is incomplete. The type hint for the return value uses the pipe operator (&lt;code&gt;|&lt;/code&gt;) to indicate alternative types of the single value that the function returns. To define the same function in Python versions older than 3.10, you can use an alternative syntax:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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 python highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;typing&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Union&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;parse_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Union&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;@&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;@&quot;&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;username&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 function uses the &lt;a href=&quot;https://docs.python.org/3/library/typing.html#typing.Union&quot;&gt;&lt;code&gt;Union&lt;/code&gt;&lt;/a&gt; type from the &lt;code&gt;typing&lt;/code&gt; module to indicate that &lt;code&gt;parse_email()&lt;/code&gt; returns either a string or &lt;code&gt;None&lt;/code&gt;, depending on the input value. Whether you use the old or new syntax, a union type hint can combine more than two data types.&lt;/p&gt;
&lt;p&gt;Even when using a modern Python release, you may still prefer the &lt;code&gt;Union&lt;/code&gt; type over the pipe operator if your code needs to run in older Python versions.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; One challenge with functions that may return different types is that you need to check the return type when you call the function. In the examples above, you need to test whether you got &lt;code&gt;None&lt;/code&gt; when parsing the email address.&lt;/p&gt;
&lt;p&gt;If the return type can be deduced from the argument types, then you can alternatively use &lt;a href=&quot;https://mypy.readthedocs.io/en/stable/more_types.html#function-overloading&quot;&gt;&lt;code&gt;@overload&lt;/code&gt;&lt;/a&gt; to specify different type signatures.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now that you know how to define a function that returns a single value of potentially different types, you can turn your attention toward using type hints to declare that a function can return more than one piece of data.&lt;/p&gt;
&lt;h2 id=&quot;use-pythons-type-hints-for-multiple-pieces-of-data-of-different-types&quot;&gt;Use Python’s Type Hints for Multiple Pieces of Data of Different Types&lt;a class=&quot;headerlink&quot; href=&quot;#use-pythons-type-hints-for-multiple-pieces-of-data-of-different-types&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sometimes, a function returns more than one value, and you can communicate this in Python using type hints. You can use a &lt;a href=&quot;https://realpython.com/python-tuple/&quot;&gt;tuple&lt;/a&gt; to indicate the types of the individual pieces of data that a function returns at once. In Python 3.9 and later, you can use built-in &lt;code&gt;tuple&lt;/code&gt; &lt;a href=&quot;https://realpython.com/python-data-structures/&quot;&gt;data structure&lt;/a&gt;. On older versions, you need to use &lt;code&gt;typing.Tuple&lt;/code&gt; in your annotations.&lt;/p&gt;
&lt;p&gt;Now, consider a scenario where you want to build on the previous example. You aim to declare a function whose return value incorporates multiple pieces of data of various types. In addition to returning the username obtained from an email address, you want to update the function to return the &lt;a href=&quot;https://en.wikipedia.org/wiki/Email_address#Domain&quot;&gt;domain&lt;/a&gt; as well.&lt;/p&gt;
&lt;p&gt;Here’s how you’d use type hints to indicate that the function returns a tuple with a string for the username and another string for the domain:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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 python highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;parse_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;@&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;email_address&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;@&quot;&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;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-type-hints-multiple-types/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-type-hints-multiple-types/ »&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 #178: Guiding Scientific Python Library Development</title>
      <id>https://realpython.com/podcasts/rpp/178/</id>
      <link href="https://realpython.com/podcasts/rpp/178/"/>
      <updated>2023-10-27T12:00:00+00:00</updated>
      <summary>How do you prepare a scientific Python project for sharing with others? Could you use some best practices and guidance for packaging, documentation, and testing? 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 do you prepare a scientific Python project for sharing with others? Could you use some best practices and guidance for packaging, documentation, and testing? 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>Boost Your Coding Productivity With Ptpython</title>
      <id>https://realpython.com/ptpython-shell/</id>
      <link href="https://realpython.com/ptpython-shell/"/>
      <updated>2023-10-25T14:00:00+00:00</updated>
      <summary>Learn how to enhance your Python development workflow with auto-completion, syntax highlighting, history navigation, and more. In this tutorial, you&#x27;ll walk through the fundamentals of ptpython, covering installation, basic usage, and advanced features.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/prompt-toolkit/ptpython&quot;&gt;Ptpython&lt;/a&gt; is a &lt;strong&gt;feature-rich&lt;/strong&gt; and &lt;strong&gt;user-friendly&lt;/strong&gt; Python REPL (Read-Eval-Print Loop) that takes your interactive Python coding experience to a whole new level. Unlike the standard &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;Python REPL&lt;/a&gt;, ptpython offers a host of powerful features designed to boost productivity and streamline the development process. Its intuitive interface, syntax highlighting, and robust auto-completion capabilities make writing and exploring Python code a breeze. &lt;/p&gt;
&lt;p&gt;The interactive shell also provides the built-in ability to inspect Python objects, so you can quickly look up &lt;strong&gt;function references&lt;/strong&gt; and &lt;strong&gt;module documentation&lt;/strong&gt; without leaving the REPL environment. Whether you’re a beginner or an experienced Python programmer, ptpython’s interactive shell and multiline editing support will help you produce quality code. &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;Install&lt;/strong&gt; and &lt;strong&gt;launch&lt;/strong&gt; ptpython&lt;/li&gt;
&lt;li&gt;Initiate &lt;strong&gt;basic commands&lt;/strong&gt; to enhance your coding experience&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;typing completion&lt;/strong&gt; and &lt;strong&gt;code auto-suggestion&lt;/strong&gt; in your interactive shell&lt;/li&gt;
&lt;li&gt;Take advantage of &lt;strong&gt;input validation&lt;/strong&gt; and &lt;strong&gt;error handling&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Customize&lt;/strong&gt; the interactive experience to your liking&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you have a better understanding of the advantages of using this enhanced Python shell, you’ll be on your way to creating a &lt;strong&gt;unique shell experience&lt;/strong&gt; while elevating your &lt;strong&gt;Python coding workflow&lt;/strong&gt; in an interactive environment. &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 Cheat Sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/ptpython-cheat-sheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-ptpython-cheat-sheet&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download a free cheat sheet&lt;/a&gt; that sums up the most useful ptpython settings.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;installing-and-launching-ptpython&quot;&gt;Installing and Launching Ptpython&lt;a class=&quot;headerlink&quot; href=&quot;#installing-and-launching-ptpython&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It’s time to install ptpython in your machine. First, ensure that you have &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;Python installed&lt;/a&gt; in your machine. Then, head over to your command line and install &lt;code&gt;ptpython&lt;/code&gt; using the &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt; command. If you want to isolate the ptpython intallation, then you can use a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt;. Otherwise, you can install it universally, as you’ll see in this tutorial: &lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 pscon 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;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;ptpython&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;By hitting the &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt; key, you download the library and make it available on your machine. To confirm that the library has been installed, you’ll launch the shell in the next step.&lt;/p&gt;
&lt;p&gt;You’re now ready to explore your newly installed tool, which is a feature-rich Python REPL. But first, you have to launch it. While you’re still in your command prompt, enter the following command:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 pscon 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;ptpython&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;You only need this command to launch an interactive session. A new session will begin with the &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; prompt, signaling that the interactive shell is ready to accept your code. Your interface should look something like this:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/image_of_ptpython_shell.941bc7d42bfd.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/image_of_ptpython_shell.941bc7d42bfd.png&quot; width=&quot;1341&quot; height=&quot;783&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/image_of_ptpython_shell.941bc7d42bfd.png&amp;amp;w=335&amp;amp;sig=c6d4b445362da56ca0428c7c014513eb1881a07b 335w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/image_of_ptpython_shell.941bc7d42bfd.png&amp;amp;w=447&amp;amp;sig=c06522f38eeb81564cbb8bc60a560665509be632 447w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/image_of_ptpython_shell.941bc7d42bfd.png&amp;amp;w=670&amp;amp;sig=6d6edef0cdf236eb319ccfa4e80d66b1e39a1076 670w, https://files.realpython.com/media/image_of_ptpython_shell.941bc7d42bfd.png 1341w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Image of ptpython Shell&quot; data-asset=&quot;5350&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Despite sharing a lot of similarities with the Python shell, the ptpython interface adds several interesting features. For example, at the bottom of the shell window, you’ll see a menu shortcut. The menu shortcut gives you a glimpse of what you can do within the interactive shell. In later sections, you’ll get to know how the menu system is the control center of ptpython. &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; The &lt;em&gt;pt&lt;/em&gt; part of ptpython refers to &lt;a href=&quot;https://python-prompt-toolkit.readthedocs.io/&quot;&gt;Prompt Toolkit&lt;/a&gt; which is a library for building interactive command line applications that ptpyton uses under the hood.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you want to go back to the command line, then you’ll have to exit the interactive shell. There are other shortcuts that you can use to exit ptpython, but for now, you’ll use the &lt;code&gt;exit()&lt;/code&gt; command:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;exit&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;exit()&lt;/code&gt; command is the same command that you’d find in the standard Python shell. Once you enter this command in the prompt, you’ll return to the regular command line.  &lt;/p&gt;
&lt;p&gt;In the next section, you’ll come to understand the intricacies that make ptpython an attractive alternative to the standard Python shell.&lt;/p&gt;
&lt;h2 id=&quot;comparing-the-standard-python-shell-vs-ptpython&quot;&gt;Comparing the Standard Python Shell vs Ptpython&lt;a class=&quot;headerlink&quot; href=&quot;#comparing-the-standard-python-shell-vs-ptpython&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The standard Python shell offers a way to interact with Python on your computer without using a &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;code editor or an IDE&lt;/a&gt;. However, it can be a rigid tool to work with for beginners. Alternatives like &lt;a href=&quot;https://realpython.com/ipython-interactive-python-shell/&quot;&gt;IPython&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/bpython-alternative-python-repl/&quot;&gt;bpython&lt;/a&gt;, and &lt;strong&gt;ptpython&lt;/strong&gt; offer more functionality in the interactive shell. &lt;/p&gt;
&lt;p&gt;With ptpython, you can gain an advantage over the standard shell by utilizing the following functionalities, which can power up your coding experience:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#highlighting-code-syntax&quot;&gt;Code and syntax highlighting&lt;/a&gt;, a functionality that you won’t find in the Python shell&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#completing-code-while-typing&quot;&gt;Completion capabilities&lt;/a&gt; that go way beyond the Python standard shell’s tab completion and reduce errors in your coding sessions&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#applying-input-validation&quot;&gt;Input validation&lt;/a&gt; to alert you when you’re about to execute erroneous code, in contrast to the Python standard shell’s executing and returning an error&lt;/li&gt;
&lt;li&gt;A &lt;a href=&quot;#understanding-the-menu-system&quot;&gt;powerful menu&lt;/a&gt; that allows you to access other functionalities&lt;/li&gt;
&lt;li&gt;The ability to seamlessly &lt;a href=&quot;#customizing-ptpython&quot;&gt;customize&lt;/a&gt; the ptpython interface by changing code color and shell behavior&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These differences make ptpython a suitable alternative if you want to have a richer and more interactive experience as you code. This powerful interactive shell offers more tools, as you’ll learn in the next section.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/ptpython-shell/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ptpython-shell/ »&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: Building Systems With Classes</title>
      <id>https://realpython.com/courses/building-systems-classes-exercises/</id>
      <link href="https://realpython.com/courses/building-systems-classes-exercises/"/>
      <updated>2023-10-24T14:00:00+00:00</updated>
      <summary>In this Python Basics Exercises course, you&#x27;ll review how to work with classes to build complex systems in Python. By practicing composing classes, inheriting from other classes, and overriding class behavior, you&#x27;ll harness the power of object-oriented programming (OOP).</summary>
      <content type="html">
        &lt;p&gt;In &lt;a href=&quot;https://realpython.com/courses/python-basics-class/&quot;&gt;Python Basics: Building Systems With Classes&lt;/a&gt;, you moved beyond the basics of object-oriented programming (OOP), and started to put those classes to work. In this exercise course you will employ these capabilities to build more complex systems and write readable, reusable code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll practice the following:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Compose&lt;/strong&gt; classes together to create layers of functionality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inherit&lt;/strong&gt; and &lt;strong&gt;override&lt;/strong&gt; behavior from other classes to create variations&lt;/li&gt;
&lt;li&gt;Creatively &lt;strong&gt;mix&lt;/strong&gt; and &lt;strong&gt;match&lt;/strong&gt; these approaches&lt;/li&gt;
&lt;li&gt;Instantiate classes with &lt;strong&gt;attributes&lt;/strong&gt; and &lt;strong&gt;methods&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Override&lt;/strong&gt; methods from a parent class&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;. &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. If you&amp;rsquo;re just getting started, 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>
  
    <entry>
      <title>How to Run Your Python Scripts and Code</title>
      <id>https://realpython.com/run-python-scripts/</id>
      <link href="https://realpython.com/run-python-scripts/"/>
      <updated>2023-10-23T14:00:00+00:00</updated>
      <summary>A Python script or program is a file containing executable Python code. Being able to run Python scripts and code is probably the most important skill that you need as a Python developer. By running your code, you&#x27;ll know if it works as planned.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;A Python &lt;strong&gt;script&lt;/strong&gt; or &lt;strong&gt;program&lt;/strong&gt; is a file containing executable Python code. Being able to run Python scripts and code is probably the most important skill that you need as a Python developer. By running your code, you’ll know if it works as planned. You’ll also be able to test and debug the code to fix errors and issues. Ultimately, you write code in order to run it and accomplish tasks.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn about some of the techniques for running Python scripts and code. The technique that you’ll use in each situation will depend on your environment, platform, needs, and skills.&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;Run Python scripts from your operating system’s &lt;strong&gt;command line&lt;/strong&gt; or &lt;strong&gt;terminal&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Execute Python code and scripts in &lt;strong&gt;interactive mode&lt;/strong&gt; using the standard REPL&lt;/li&gt;
&lt;li&gt;Use your favorite &lt;strong&gt;IDE&lt;/strong&gt; or &lt;strong&gt;code editor&lt;/strong&gt; to run your Python scripts&lt;/li&gt;
&lt;li&gt;Fire up your scripts and programs from your operating system’s &lt;strong&gt;file manager&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should know the basics of working with your operating system’s &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt; and file manager. It’d also be beneficial for you to be familiar with a Python-friendly &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;IDE or code editor&lt;/a&gt; and with the standard Python &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt; (Read-Eval-Print Loop).&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-tricks-sample-pdf/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-tricks-sample-pdf&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Get a sample chapter from Python Tricks: The Book&lt;/a&gt; that shows you Python’s best practices with simple examples you can apply instantly to write more beautiful + Pythonic code.&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;i class=&quot;fa fa-graduation-cap&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt; Take the Quiz:&lt;/strong&gt; Test your knowledge with our interactive “How to Run Your Python Scripts” 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/run-python-scripts/&quot; target=&quot;_blank&quot;&gt;Take the Quiz »&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;what-scripts-and-modules-are&quot;&gt;What Scripts and Modules Are&lt;a class=&quot;headerlink&quot; href=&quot;#what-scripts-and-modules-are&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In computing, the term &lt;strong&gt;script&lt;/strong&gt; refers to a text file containing a logical sequence of orders that you can run to accomplish a specific task. These orders are typically expressed in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Scripting_language&quot;&gt;scripting language&lt;/a&gt;, which is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Programming_language&quot;&gt;programming language&lt;/a&gt; that allows you to manipulate, customize, and automate tasks.&lt;/p&gt;
&lt;p&gt;Scripting languages are usually &lt;a href=&quot;https://en.wikipedia.org/wiki/Interpreter_(computing)&quot;&gt;interpreted&lt;/a&gt; at &lt;a href=&quot;https://en.wikipedia.org/wiki/Runtime_(program_lifecycle_phase)&quot;&gt;runtime&lt;/a&gt; rather than &lt;a href=&quot;https://en.wikipedia.org/wiki/Compiler&quot;&gt;compiled&lt;/a&gt;. So, scripts are typically run by some kind of interpreter, which is responsible for executing each order in a sequence.&lt;/p&gt;
&lt;p&gt;Python is an interpreted language. Because of that, Python programs are commonly called scripts. However, this terminology isn’t completely accurate because Python programs can be way more complex than a simple, sequential script.&lt;/p&gt;
&lt;p&gt;In general, a file containing executable Python code is called a script—or an &lt;strong&gt;entry-point script&lt;/strong&gt; in more complex applications—which is a common term for a top-level &lt;strong&gt;program&lt;/strong&gt;. On the other hand, a file containing Python code that’s designed to be imported and used from another Python file is called a &lt;strong&gt;module&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;So, the main difference between a &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;module&lt;/a&gt; and a script is that modules store &lt;strong&gt;importable code&lt;/strong&gt; while scripts hold &lt;strong&gt;executable code&lt;/strong&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; Importable code is code that defines something but doesn’t perform a specific action. Some examples include function and class definitions. In contrast, executable code is code that performs specific actions. Some examples include &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/#function-calls-and-definition&quot;&gt;function calls&lt;/a&gt;, loops, and &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditionals&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In the following sections, you’ll learn how to run Python scripts, programs, and code in general. To kick things off, you’ll start by learning how to run them from your operating system’s command line or terminal.&lt;/p&gt;
&lt;h2 id=&quot;how-to-run-python-scripts-from-the-command-line&quot;&gt;How to Run Python Scripts From the Command Line&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-run-python-scripts-from-the-command-line&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python programming, you’ll write programs in plain text files. By convention, files containing Python code use the &lt;code&gt;.py&lt;/code&gt; extension, and there’s no distinction between scripts or executable programs and modules. All of them will use the same extension.&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; On &lt;a href=&quot;https://realpython.com/python-coding-setup-windows/&quot;&gt;Windows&lt;/a&gt; systems, the extension can also be &lt;code&gt;.pyw&lt;/code&gt; for those applications that should use the &lt;code&gt;pythonw.exe&lt;/code&gt; launcher.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To create a Python script, you can use any Python-friendly &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;code editor or IDE&lt;/a&gt; (integrated development environment). To keep moving forward in this tutorial, you’ll need to create a basic script, so fire up your favorite text editor and create a new &lt;code&gt;hello.py&lt;/code&gt; file containing the following code:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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 python highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# hello.py&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;Hello, World!&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 is the classic &lt;code&gt;&quot;Hello, World!&quot;&lt;/code&gt; program in Python. The executable code consists of a call to the built-in &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; function that displays the &lt;code&gt;&quot;Hello, World!&quot;&lt;/code&gt; message on your screen.&lt;/p&gt;
&lt;p&gt;With this small program ready, you’re ready to learn different ways to run it. You’ll start by running the program from your command line, which is arguably the most commonly used approach to running scripts.&lt;/p&gt;
&lt;h3 id=&quot;using-the-python-command&quot;&gt;Using the &lt;code&gt;python&lt;/code&gt; Command&lt;a class=&quot;headerlink&quot; href=&quot;#using-the-python-command&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To run Python scripts with the &lt;code&gt;python&lt;/code&gt; command, you need to open a command-line window and type in the word &lt;code&gt;python&lt;/code&gt; followed by the path to your target script:&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.4bb4395d5bcd.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.4bb4395d5bcd.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.4bb4395d5bcd.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&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/run-python-scripts/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/run-python-scripts/ »&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 #177: Welcoming PyPI&#x27;s Safety &amp; Security Engineer Mike Fiedler</title>
      <id>https://realpython.com/podcasts/rpp/177/</id>
      <link href="https://realpython.com/podcasts/rpp/177/"/>
      <updated>2023-10-20T12:00:00+00:00</updated>
      <summary>You may remember a recent Python Package Index (PyPI) announcement about hiring a full-time security engineer. We&#x27;ve also mentioned several current security initiatives from PyPI. This week on the show, we talk with Mike Fiedler about accepting this new role and securing accounts on PyPI.</summary>
      <content type="html">
        &lt;p&gt;You may remember a recent Python Package Index (PyPI) announcement about hiring a full-time security engineer. We&#x27;ve also mentioned several current security initiatives from PyPI. This week on the show, we talk with Mike Fiedler about accepting this new role and securing accounts on PyPI.&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 F-String for String Interpolation and Formatting</title>
      <id>https://realpython.com/python-f-strings/</id>
      <link href="https://realpython.com/python-f-strings/"/>
      <updated>2023-10-18T14:00:00+00:00</updated>
      <summary>Python&#x27;s f-string provides a readable way to interpolate and format strings. They&#x27;re readable, concise, and less prone to error than traditional string interpolation and formatting tools, such as the .format() method and the modulo operator (%). F-strings are also faster than those tools!</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python &lt;strong&gt;f-strings&lt;/strong&gt; provide a quick way to &lt;strong&gt;interpolate&lt;/strong&gt; and &lt;strong&gt;format&lt;/strong&gt; strings. They’re readable, concise, and less prone to error than traditional string interpolation and formatting tools, such as the &lt;code&gt;.format()&lt;/code&gt; method and the modulo operator (&lt;code&gt;%&lt;/code&gt;). An f-string is also a bit faster than those tools!&lt;/p&gt;
&lt;p&gt;By the end of this tutorial, you’ll know why f-strings are such a powerful tool that you should learn and master as a Python developer.&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;Interpolate&lt;/strong&gt; values, objects, and expressions into your strings using &lt;strong&gt;f-strings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Format&lt;/strong&gt; f-strings using Python’s &lt;strong&gt;string formatting mini-language&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Leverage some &lt;strong&gt;cool features&lt;/strong&gt; of f-strings in Python 3.12 and beyond&lt;/li&gt;
&lt;li&gt;Decide when to use &lt;strong&gt;traditional interpolation&lt;/strong&gt; tools instead of &lt;strong&gt;f-strings&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with Python’s &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;string&lt;/a&gt; data type. It’s also be beneficial to have experience with other string interpolation tools like the modulo operator (&lt;code&gt;%&lt;/code&gt;) and the &lt;code&gt;.format()&lt;/code&gt; method.&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-f-string-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-f-string-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 do string interpolation and formatting with Python’s f-strings.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;interpolating-and-formatting-strings-before-python-36&quot;&gt;Interpolating and Formatting Strings Before Python 3.6&lt;a class=&quot;headerlink&quot; href=&quot;#interpolating-and-formatting-strings-before-python-36&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before Python 3.6, you had two main tools for interpolating values, variables, and expressions inside string literals:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting&quot;&gt;string interpolation operator&lt;/a&gt; (&lt;code&gt;%&lt;/code&gt;), or modulo operator&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#str.format&quot;&gt;&lt;code&gt;str.format()&lt;/code&gt;&lt;/a&gt; method&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You’ll get a refresher on these two string interpolation tools in the following sections. You’ll also learn about the string formatting capabilities that these tools offer in Python.&lt;/p&gt;
&lt;h3 id=&quot;the-modulo-operator&quot;&gt;The Modulo Operator, &lt;code&gt;%&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#the-modulo-operator&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The modulo operator (&lt;code&gt;%&lt;/code&gt;) was the first tool for string interpolation and formatting in Python and has been in the language since the beginning. Here’s what using this operator looks like in practice:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;s2&quot;&gt;&quot;Jane&quot;&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;%s&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;name&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Hello, Jane!&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 quick example, you use the &lt;code&gt;%&lt;/code&gt; operator to interpolate the value of your &lt;code&gt;name&lt;/code&gt; variable into a string literal. The interpolation operator takes two operands:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A string literal containing one or more conversion specifiers&lt;/li&gt;
&lt;li&gt;The object or objects that you’re interpolating into the string literal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;strong&gt;conversion specifiers&lt;/strong&gt; work as replacement fields. In the above example, you use the &lt;code&gt;%s&lt;/code&gt; combination of characters as a conversion specifier. The &lt;code&gt;%&lt;/code&gt; symbol marks the start of the specifier, while the &lt;code&gt;s&lt;/code&gt; letter is the &lt;strong&gt;conversion type&lt;/strong&gt; and tells the operator that you want to convert the input object into a string.&lt;/p&gt;
&lt;p&gt;If you want to insert more than one object into your target string, then you can use a &lt;a href=&quot;https://realpython.com/python-tuple/&quot;&gt;tuple&lt;/a&gt;. Note that the number of objects in the tuple must match the number of format specifiers in the string:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;s2&quot;&gt;&quot;Jane&quot;&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;age&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&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;%s&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;! You&#x27;re &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; years old.&quot;&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;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Hello, Jane! You&#x27;re 25 years old.&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 use a tuple of values as the right-hand operand to &lt;code&gt;%&lt;/code&gt;. Note that you’ve used a string and an integer. Because you use the &lt;code&gt;%s&lt;/code&gt; specifier, Python converts both objects to strings.&lt;/p&gt;
&lt;p&gt;You can also use dictionaries as the right-hand operand in your interpolation expressions. To do this, you need to create conversion specifiers that enclose key names in parentheses:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;%(name)s&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;! You&#x27;re &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%(age)s&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; years old.&quot;&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;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Jane&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&quot;Hello, Jane! You&#x27;re 25 years old.&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 syntax provides a readable approach to string interpolation with the &lt;code&gt;%&lt;/code&gt; operator. You can use descriptive key names instead of relying on the positional order of values.&lt;/p&gt;
&lt;p&gt;When you use the &lt;code&gt;%&lt;/code&gt; operator for string interpolation, you can use conversion specifiers. They provide some string formatting capabilities that take advantage of &lt;strong&gt;conversion types&lt;/strong&gt;, &lt;strong&gt;conversion flags&lt;/strong&gt;, and some characters like the period (&lt;code&gt;.&lt;/code&gt;) and the asterisk (&lt;code&gt;*&lt;/code&gt;). Consider the following example:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;Balance: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%.2f&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;mf&quot;&gt;5425.9292&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Balance: $5425.93&#x27;&lt;/span&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;s2&quot;&gt;&quot;Name: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Age: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;%5s&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;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;John&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Name: John&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Age:    35&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 the &lt;code&gt;%.2f&lt;/code&gt; conversion specifier to represent currency values. The &lt;code&gt;f&lt;/code&gt; letter tells the operator to convert to a floating-point number. The &lt;code&gt;.2&lt;/code&gt; part defines the precision to use when converting the input. In the second example, you use &lt;code&gt;%5s&lt;/code&gt; to align the age value five positions to the right.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-f-strings/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-f-strings/ »&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: Object-Oriented Programming</title>
      <id>https://realpython.com/courses/object-oriented-programming-exercises/</id>
      <link href="https://realpython.com/courses/object-oriented-programming-exercises/"/>
      <updated>2023-10-17T14:00:00+00:00</updated>
      <summary>In this Python Basics Exercises course, you&#x27;ll review OOP, or object-oriented programming. You&#x27;ll practice creating classes, using classes to create new objects, and instantiating classes with attributes.</summary>
      <content type="html">
        &lt;p&gt;In &lt;a href=&quot;https://realpython.com/courses/python-basics-oop/&quot;&gt;Python Basics: Object-Oriented Programming&lt;/a&gt;, you learned how OOP, or object-oriented programming, is a method of structuring a program by bundling related properties and behaviors into individual objects.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll practice the following:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;strong&gt;&lt;code&gt;class&lt;/code&gt;&lt;/strong&gt;, which is like a blueprint for creating an object&lt;/li&gt;
&lt;li&gt;Use classes to create new &lt;strong&gt;objects&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Instantiate classes with &lt;strong&gt;attributes&lt;/strong&gt; and &lt;strong&gt;methods&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use dunder methods like &lt;strong&gt;init&lt;/strong&gt;() and &lt;strong&gt;str&lt;/strong&gt;()&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>Build a Blog From Scratch With Django</title>
      <id>https://realpython.com/build-a-blog-from-scratch-django/</id>
      <link href="https://realpython.com/build-a-blog-from-scratch-django/"/>
      <updated>2023-10-16T14:00:00+00:00</updated>
      <summary>In this Django beginner project, you&#x27;ll build a blog from scratch with the Django web framework. You&#x27;ll leverage the Django admin site and explore how to work with forms so your visitors can comment on your posts.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;There are plenty of blogging platforms out there that you can use out of the box. However, building your own blog from scratch with Django is a great way to keep control over your content. Even if you’re just getting started with Django, its user-friendly features will allow you to focus on designing and posting your content.&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;Set up a new &lt;strong&gt;Django project&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create and edit &lt;strong&gt;blog posts&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Display posts&lt;/strong&gt; to the user&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assign categories&lt;/strong&gt; to posts&lt;/li&gt;
&lt;li&gt;Allow users to &lt;strong&gt;comment on posts&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you’ll leverage the Django admin site and explore how to work with forms in Django. This is an ideal project to dip your toes into the world of Django, but you should have a solid foundation in &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python basics&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;At the end of this tutorial, you’ll be able to share your knowledge through a working blog that you’ve built from scratch. If you’re curious about how the final &lt;strong&gt;source code&lt;/strong&gt; looks, then you can click the link below:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-a-blog-from-scratch-django-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-a-blog-from-scratch-django-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your free source code&lt;/a&gt; to build a blog from scratch with Django.&lt;/p&gt;
&lt;/div&gt;
&lt;h3 id=&quot;set-up-the-development-environment&quot;&gt;Set Up the Development Environment&lt;a class=&quot;headerlink&quot; href=&quot;#set-up-the-development-environment&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Whenever you’re starting a new web development project, it’s a good idea to first set up your development environment. Create a new directory for your project to live in, and &lt;code&gt;cd&lt;/code&gt; into it:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 sh 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;mkdir&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;django-blog
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;django-blog
&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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’re inside the &lt;code&gt;django-blog/&lt;/code&gt; directory, it’s a good idea to create a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt; to manage dependencies. Select your &lt;strong&gt;operating system&lt;/strong&gt; below and use your platform-specific command to set up a virtual environment:&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.4bb4395d5bcd.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.4bb4395d5bcd.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.4bb4395d5bcd.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;&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.4bb4395d5bcd.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 pscon 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;python&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;&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.4bb4395d5bcd.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 sh 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;venv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv
&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 command will create a &lt;code&gt;venv/&lt;/code&gt; folder in your working directory. Inside this directory, you’ll find several files, including a copy of the Python standard library. Later, when you install new dependencies, this directory will store them too. Next, you need to activate the virtual environment by running the following command:&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.4bb4395d5bcd.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.4bb4395d5bcd.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.4bb4395d5bcd.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;&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.4bb4395d5bcd.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 pscon 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;p&quot;&gt;.\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Scripts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;activate&lt;/span&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;/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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;&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.4bb4395d5bcd.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 sh 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;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv/bin/activate
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;With the above commands, you create and activate a virtual environment named &lt;code&gt;venv&lt;/code&gt; by using Python’s built-in &lt;code&gt;venv&lt;/code&gt; module. The parenthetical &lt;code&gt;(venv)&lt;/code&gt; in front of the prompt indicates that you’ve successfully activated the virtual environment.&lt;/p&gt;
&lt;p&gt;Now that you’ve created and activated a virtual environment, it’s time to install Django. You can do this using &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;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 sh 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;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;Django
&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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’ve set up the virtual environment and installed Django, you can now dive into creating your Django project.&lt;/p&gt;
&lt;h2 id=&quot;start-your-django-project&quot;&gt;Start Your Django Project&lt;a class=&quot;headerlink&quot; href=&quot;#start-your-django-project&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A Django web application is made up of a &lt;strong&gt;project&lt;/strong&gt; and &lt;strong&gt;apps&lt;/strong&gt;. A Django project holds some configurations that apply to the web application as a whole, such as project settings, URLs, shared templates, and static files. Each Django app can have its own URLs as well as its own HTML templates and static files, such as &lt;a href=&quot;https://realpython.com/python-vs-javascript/&quot;&gt;JavaScript&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/html-css-python/#style-your-content-with-css&quot;&gt;CSS&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create your Django project, make sure you’re in the &lt;code&gt;django-blog/&lt;/code&gt; directory with your virtual environment activated. Then, run the following command to create the &lt;code&gt;personal_blog&lt;/code&gt; project:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 sh 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;django-admin&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;startproject&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;personal_blog&lt;span class=&quot;w&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;Don’t forget to add the dot (&lt;code&gt;.&lt;/code&gt;) at the end of the command above. The dot prevents Django from creating a nested project directory for your portfolio project. Otherwise you’d end up with a &lt;code&gt;personal_blog/&lt;/code&gt; folder that contains a &lt;code&gt;personal_blog/&lt;/code&gt; subdirectory.&lt;/p&gt;
&lt;p&gt;By running the &lt;code&gt;startproject&lt;/code&gt; command as shown above, you’ve told Django to create one &lt;code&gt;personal_blog/&lt;/code&gt; folder in the &lt;code&gt;django-blog/&lt;/code&gt; directory. Your directory structure should look something like this:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/build-a-blog-from-scratch-django/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/build-a-blog-from-scratch-django/ »&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 #176: Building Python Best Practices and Fundamental Skills</title>
      <id>https://realpython.com/podcasts/rpp/176/</id>
      <link href="https://realpython.com/podcasts/rpp/176/"/>
      <updated>2023-10-13T12:00:00+00:00</updated>
      <summary>What fundamental developer skills are new Python users missing? What best practices might developers without a computer science background be lacking? 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 fundamental developer skills are new Python users missing? What best practices might developers without a computer science background be lacking? 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>How to Sort Unicode Strings Alphabetically in Python</title>
      <id>https://realpython.com/python-sort-unicode-strings/</id>
      <link href="https://realpython.com/python-sort-unicode-strings/"/>
      <updated>2023-10-11T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to correctly sort Unicode strings in Python while avoiding common pitfalls. You&#x27;ll explore powerful third-party libraries implementing the complete Unicode Collation Algorithm (UCA), as well as standard library modules and a few handmade solutions.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Sorting strings in Python is something that you can almost take for granted if you do it all the time. Yet, it can become surprisingly tricky considering all the edge cases lurking in the vast &lt;a href=&quot;https://realpython.com/python-encodings-guide/&quot;&gt;Unicode&lt;/a&gt; standard. Understanding Unicode isn’t an easy feat, so prepare yourself for a whirlwind tour of surprising edge cases and effective ways of dealing with them.&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; In this tutorial, you’ll often use the term &lt;strong&gt;Unicode string&lt;/strong&gt; to mean any string with non-Latin letters and characters like &lt;a href=&quot;https://en.wikipedia.org/wiki/Emoji&quot;&gt;emoji&lt;/a&gt;. However, strings consisting of &lt;a href=&quot;https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)&quot;&gt;Basic Latin&lt;/a&gt; letters also fall into this category because the underlying &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot;&gt;ASCII&lt;/a&gt; table is a subset of Unicode.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Python pioneered and popularized a robust &lt;a href=&quot;https://realpython.com/sorting-algorithms-python/&quot;&gt;sorting algorithm&lt;/a&gt; called &lt;a href=&quot;https://en.wikipedia.org/wiki/Timsort&quot;&gt;Timsort&lt;/a&gt;, which now ships with several major programming languages, including &lt;a href=&quot;https://realpython.com/java-vs-python/&quot;&gt;Java&lt;/a&gt;, Rust, and Swift. When you call &lt;a href=&quot;https://realpython.com/python-sort/&quot;&gt;&lt;code&gt;sorted()&lt;/code&gt; or &lt;code&gt;list.sort()&lt;/code&gt;&lt;/a&gt;, Python uses this algorithm under the surface to rearrange elements. As long as your sequence contains &lt;strong&gt;comparable elements&lt;/strong&gt; of compatible types, then you can sort &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, and other data types in the expected order:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;math_constants&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;mf&quot;&gt;6.28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.72&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;3.14&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;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;math_constants&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[2.72, 3.14, 6.28]&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;fruits&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;s2&quot;&gt;&quot;orange&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;banana&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;lemon&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;apple&quot;&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;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&#x27;apple&#x27;, &#x27;banana&#x27;, &#x27;lemon&#x27;, &#x27;orange&#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;people&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;s2&quot;&gt;&quot;John&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Doe&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Anna&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Smith&quot;&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;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;people&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[(&#x27;Anna&#x27;, &#x27;Smith&#x27;), (&#x27;John&#x27;, &#x27;Doe&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;Unless you specify otherwise, Python sorts these elements &lt;em&gt;by value&lt;/em&gt; in ascending order, comparing them pairwise. Each pair must contain elements that are comparable using either the &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__lt__&quot;&gt;less than (&lt;code&gt;&amp;lt;&lt;/code&gt;)&lt;/a&gt; or &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__gt__&quot;&gt;greater than (&lt;code&gt;&amp;gt;&lt;/code&gt;)&lt;/a&gt; operator. Sometimes, these &lt;a href=&quot;https://realpython.com/python-operators-expressions/#comparison-operators&quot;&gt;comparison operators&lt;/a&gt; are undefined for specific data types like &lt;a href=&quot;https://realpython.com/python-complex-numbers/&quot;&gt;complex numbers&lt;/a&gt; or between two distinct types. In these cases, a comparison will fail:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;mi&quot;&gt;4&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;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&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;TypeError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;&#x27;&amp;lt;&#x27; not supported between instances of &#x27;complex&#x27; and &#x27;complex&#x27;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;orange&quot;&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;TypeError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;&#x27;&amp;lt;&#x27; not supported between instances of &#x27;float&#x27; and &#x27;str&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 most cases, you’ll be working with homogeneous sequences comprising elements of the same type, so you’ll rarely run into this problem in the wild. However, things may start to fall apart once you throw strings with non-Latin characters into the mix, such as letters with &lt;a href=&quot;https://en.wikipedia.org/wiki/Diacritic&quot;&gt;diacritics&lt;/a&gt; or accents:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;polish_names&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;s2&quot;&gt;&quot;Zbigniew&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Ludmiła&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Żaneta&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Łukasz&quot;&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;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;polish_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&#x27;Ludmiła&#x27;, &#x27;Zbigniew&#x27;, &#x27;Łukasz&#x27;, &#x27;Żaneta&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 run into a common challenge associated with sorting strings. When a string contains characters whose &lt;strong&gt;ordinal values&lt;/strong&gt; extend beyond the usual ASCII range, then you might get unexpected results like what you have here. The name &lt;em&gt;Łukasz&lt;/em&gt; ends up after &lt;em&gt;Zbigniew&lt;/em&gt;, even though the letter &lt;a href=&quot;https://en.wikipedia.org/wiki/%C5%81&quot;&gt;&lt;em&gt;Ł&lt;/em&gt;&lt;/a&gt; (pronounced like a &lt;em&gt;w&lt;/em&gt; sound in English) occurs earlier than &lt;em&gt;Z&lt;/em&gt; in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Polish_alphabet&quot;&gt;Polish alphabet&lt;/a&gt;. Why’s that?&lt;/p&gt;
&lt;p&gt;Python sorts strings &lt;a href=&quot;https://en.wikipedia.org/wiki/Lexicographic_order&quot;&gt;lexicographically&lt;/a&gt; by comparing Unicode &lt;a href=&quot;https://en.wikipedia.org/wiki/Code_point&quot;&gt;code points&lt;/a&gt; of the individual characters from left to right. It just so happens that the letter &lt;em&gt;Ł&lt;/em&gt; has a higher ordinal value in Unicode than the letter &lt;em&gt;Z&lt;/em&gt;, making it greater than any of the Latin letters:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;ord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ł&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;321&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ord&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;90&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;any&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ł&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;letter&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;letter&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;False&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;Code points are unique yet arbitrary identifiers of Unicode characters, and they don’t inherently agree with the &lt;a href=&quot;https://en.wikipedia.org/wiki/Alphabetical_order&quot;&gt;alphabetical order&lt;/a&gt; of spoken languages. So, lexicographic sorting won’t be appropriate for languages other than English.&lt;/p&gt;
&lt;p&gt;Different cultures follow different rules for sorting strings, even when they share the same alphabet or parts of it with other cultures. For example, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Ch_(digraph)&quot;&gt;&lt;em&gt;ch&lt;/em&gt; digraph&lt;/a&gt; is considered two separate letters (&lt;em&gt;c&lt;/em&gt; and &lt;em&gt;h&lt;/em&gt;) in Polish, but it becomes a stand-alone letter placed between &lt;em&gt;h&lt;/em&gt; and &lt;em&gt;i&lt;/em&gt; in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Czech_orthography#Alphabet&quot;&gt;Czech alphabet&lt;/a&gt;. This is known as a &lt;a href=&quot;https://unicode-org.github.io/icu/userguide/collation/concepts.html#contractions&quot;&gt;contraction&lt;/a&gt; in Unicode.&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; Language rules occasionally change. For instance, the Spanish alphabet treated the &lt;em&gt;ch&lt;/em&gt; and &lt;em&gt;ll&lt;/em&gt; digraphs as single letters until 1994, when the official language regulation institution, &lt;a href=&quot;https://en.wikipedia.org/wiki/Royal_Spanish_Academy&quot;&gt;RAE&lt;/a&gt;, declared them separate.&lt;/p&gt;
&lt;p&gt;At some point, the &lt;a href=&quot;https://unicode-org.github.io/icu/userguide/collation/concepts.html#backward-secondary-sorting&quot;&gt;accent ordering&lt;/a&gt; in French changed from backward to forward everywhere in the world except for Canada, which still sticks to the old tradition:&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;&lt;/th&gt;
&lt;th&gt;Accent Ordering&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;France&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;cote&lt;/em&gt;, &lt;em&gt;coté&lt;/em&gt;, &lt;em&gt;côte&lt;/em&gt;, &lt;em&gt;côté&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Canada&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;cote&lt;/em&gt;, &lt;em&gt;côte&lt;/em&gt;, &lt;em&gt;coté&lt;/em&gt;, &lt;em&gt;côté&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;In modern French, words are compared from left to right. The earliest letter with an accent, which is &lt;em&gt;ô&lt;/em&gt; in the example above, corresponds to a greater sort key, pushing the word to the end of the list. On the other hand, in Canada, words are compared backward from right to left, so the last accent’s position determines the final order.&lt;/p&gt;
&lt;p&gt;Depending on their geographic location worldwide, individuals speaking the same language may expect a slightly different sorting order.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Moreover, the sorting order can sometimes differ within the same culture, depending on the context. For example, most German phone books tend to treat letters with an &lt;a href=&quot;https://en.wikipedia.org/wiki/Diaeresis_(diacritic)&quot;&gt;umlaut&lt;/a&gt; (&lt;em&gt;ä&lt;/em&gt;, &lt;em&gt;ö&lt;/em&gt;, &lt;em&gt;ü&lt;/em&gt;)  similarly to the &lt;em&gt;ae&lt;/em&gt;, &lt;em&gt;oe&lt;/em&gt;, and &lt;em&gt;ue&lt;/em&gt; letter combinations. However, other countries overwhelmingly treat these letters the same as their Latin counterparts (&lt;em&gt;a&lt;/em&gt;, &lt;em&gt;o&lt;/em&gt;, &lt;em&gt;u&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;There’s no universally correct way to sort Unicode strings. You need to tell Python which rules to apply to get the desired ordering. So, &lt;strong&gt;how do you sort Unicode strings alphabetically in Python?&lt;/strong&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-sort-unicode-strings-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-sort-unicode-strings-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 sort Unicode strings alphabetically with Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-sort-strings-using-the-unicode-collation-algorithm-uca&quot;&gt;How to Sort Strings Using the Unicode Collation Algorithm (UCA)&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-sort-strings-using-the-unicode-collation-algorithm-uca&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The problem of sorting Unicode strings isn’t unique to Python. It’s a common challenge in any programming language or database. To address it, &lt;a href=&quot;https://unicode.org/reports/tr10/&quot;&gt;Technical Report #10&lt;/a&gt; in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Unicode_Technical_Standard&quot;&gt;Unicode Technical Standard (UTS)&lt;/a&gt; describes the &lt;a href=&quot;https://en.wikipedia.org/wiki/Collation&quot;&gt;collation&lt;/a&gt; of Unicode strings, which is a consistent way of comparing two strings to establish their sorting order.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Unicode_collation_algorithm&quot;&gt;Unicode Collation Algorithm (UCA)&lt;/a&gt; assigns a hierarchy of numeric weights to each character, allowing the creation of &lt;strong&gt;binary sort keys&lt;/strong&gt; that account for accents and other special cases. These keys are defined at four levels that determine various features of a character:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Primary:&lt;/strong&gt; The base letter&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secondary:&lt;/strong&gt; The accents&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tertiary:&lt;/strong&gt; The letter case&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Quaternary:&lt;/strong&gt; Other features&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Later in this tutorial, you’ll learn how to leverage these weight levels to customize the Unicode collation algorithm by, for example, ignoring the letter case in &lt;a href=&quot;#perform-case-insensitive-sorting-of-unicode-strings&quot;&gt;case-insensitive&lt;/a&gt; sorting.&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; This hierarchical nature of character weights allows you to compare sort keys incrementally to increase performance. It also helps conserve memory. For example, some implementations of the UCA take advantage of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Trie&quot;&gt;trie data structure&lt;/a&gt; to efficiently store and retrieve the weights for a given string.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;While the UCA supplies the &lt;a href=&quot;https://www.unicode.org/Public/UCA/15.0.0/allkeys.txt&quot;&gt;Default Unicode Collation Element Table (DUCET)&lt;/a&gt;, you should generally customize this default collation table to the specific needs of a particular language and application. It’s virtually impossible to ensure the desired sort order for all languages using only one character table. Therefore, software libraries implementing the UCA usually rely on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Common_Locale_Data_Repository&quot;&gt;Common Locale Data Repository (CLDR)&lt;/a&gt; to provide such customization.&lt;/p&gt;
&lt;p&gt;This repository contains several &lt;a href=&quot;https://realpython.com/python-xml-parser/&quot;&gt;XML documents&lt;/a&gt; with language-specific information. For example, the &lt;a href=&quot;https://github.com/unicode-org/cldr/blob/8b24ef40997d291336f32c949e7e3bae59b59bac/common/collation/pl.xml&quot;&gt;collation rules for sorting text in Polish&lt;/a&gt; explain the relationship between the letters &lt;em&gt;z&lt;/em&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/%C5%B9&quot;&gt;&lt;em&gt;ź&lt;/em&gt;&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/%C5%BB&quot;&gt;&lt;em&gt;ż&lt;/em&gt;&lt;/a&gt; in both uppercase and lowercase:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-sort-unicode-strings/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-sort-unicode-strings/ »&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>Using Python&#x27;s min() and max()</title>
      <id>https://realpython.com/courses/python-min-max/</id>
      <link href="https://realpython.com/courses/python-min-max/"/>
      <updated>2023-10-10T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to use Python&#x27;s built-in min() and max() functions to find the smallest and largest values. You&#x27;ll also learn how to modify their standard behavior by providing a suitable key function. Finally, you&#x27;ll code a few practical examples of using min() and max().</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s built-in &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; functions come in handy when you need to find the &lt;strong&gt;smallest&lt;/strong&gt; and &lt;strong&gt;largest&lt;/strong&gt; values in an &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-iterable&quot;&gt;iterable&lt;/a&gt; or in a series of &lt;strong&gt;regular arguments&lt;/strong&gt;. Even though these might seem like fairly basic computations, they turn out to have many interesting use cases in real-world programing. You&amp;rsquo;ll try out some of those use cases here.&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;Use Python&amp;rsquo;s &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; to find &lt;strong&gt;smallest&lt;/strong&gt; and &lt;strong&gt;largest&lt;/strong&gt; values in your data&lt;/li&gt;
&lt;li&gt;Call &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; with a single &lt;strong&gt;iterable&lt;/strong&gt; or with any number of &lt;strong&gt;regular arguments&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; with &lt;strong&gt;strings&lt;/strong&gt; and &lt;strong&gt;dictionaries&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Tweak the behavior of &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; with the &lt;strong&gt;&lt;code&gt;key&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;default&lt;/code&gt;&lt;/strong&gt; arguments&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;comprehensions&lt;/strong&gt; and &lt;strong&gt;generator expressions&lt;/strong&gt; as arguments to &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you have this knowledge under your belt, then you&amp;rsquo;ll be prepared to write a bunch of practical examples that will showcase the usefulness of &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt;. Finally, you&amp;rsquo;ll code your own versions of &lt;code&gt;min()&lt;/code&gt; and &lt;code&gt;max()&lt;/code&gt; in pure Python, which can help you understand how these functions work internally.&lt;/p&gt;
&lt;p&gt;To get the most out of this video course, you should have some previous knowledge of Python programming, including topics like &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt;, &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/list-comprehension-python/&quot;&gt;list comprehensions&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/introduction-to-python-generators/#building-generators-with-generator-expressions&quot;&gt;generator expressions&lt;/a&gt;.&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 September 2023</title>
      <id>https://realpython.com/python-news-september-2023/</id>
      <link href="https://realpython.com/python-news-september-2023/"/>
      <updated>2023-10-09T14:00:00+00:00</updated>
      <summary>In September 2023, the Python community anxiously prepared for the October arrival of Python 3.12. Microsoft integrated the Python Editor into Excel, Modular released the Mojo SDK for Linux, and the first alpha version of Django 5.0 became available.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;As the leaves turned yellow and fall set in, the Python community prepared for the release of &lt;strong&gt;Python 3.12&lt;/strong&gt; in early October. This new version of the most popular programming language brings several exciting new features, including better error messages and improvements to static typing. It also lays the groundwork for enhanced parallelism.&lt;/p&gt;
&lt;p&gt;Microsoft Excel is about to become a friendlier space for Pythonistas with the integration of the &lt;strong&gt;Python Editor&lt;/strong&gt;, opening up new possibilities for those bridging the gap between coding and data analysis.&lt;/p&gt;
&lt;p&gt;September also saw the release of the &lt;strong&gt;Mojo Software Development Kit (SDK)&lt;/strong&gt; for Linux by Modular. As a superset of Python, Mojo has been the talk of the town, offering features such as familiar syntax, Python interoperability, and unrivaled performance.&lt;/p&gt;
&lt;p&gt;Web developers weren’t left behind, with the availability of &lt;strong&gt;Django 5.0 alpha 1&lt;/strong&gt; revealing some promising enhancements. The Django community also got a chance to express their thoughts through the &lt;strong&gt;Django Developers Survey 2023&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Part of what makes Python’s growth successful is the amount of thought that goes into every change. This thoughful approach was on display in the rejection of &lt;strong&gt;PEP 713&lt;/strong&gt;, the proposal to include callable modules in Python 3.12.&lt;/p&gt;
&lt;p&gt;Let’s plunge into the most exciting Python news from September 2023!&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Join Now:&lt;/strong&gt; &lt;a href=&quot;&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-newsletter&quot; data-focus=&quot;false&quot;&gt;Click here to join the Real Python Newsletter&lt;/a&gt; and you&#x27;ll never miss another Python tutorial, course update, or post.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;python-312-arrives-in-october-2023&quot;&gt;Python 3.12 Arrives in October 2023&lt;a class=&quot;headerlink&quot; href=&quot;#python-312-arrives-in-october-2023&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although this article covers the major events of September, you’re reading it at a time when &lt;strong&gt;Python 3.12&lt;/strong&gt; has already been released. Because it’s such a big and long-awaited event in the Python community, we’ve decided to include it in this roundup.&lt;/p&gt;
&lt;p&gt;Every year in early October, a new version of Python gets released, and 2023 was no exception. Python 3.12 arrived with a range of features and improvements. While they predominantly enhance the interpreter’s internal workings, the new release still brings a few tangible benefits to the table. &lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;key new features&lt;/strong&gt; in Python 3.12 that most developers will be excited about include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-error-messages/&quot;&gt;Ever better error messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-f-strings/&quot;&gt;More intuitive and consistent f-strings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-typing/&quot;&gt;Static typing improvements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-subinterpreters/&quot;&gt;Subinterpreters with isolated GILs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-perf-profiler/&quot;&gt;Support for the Linux &lt;code&gt;perf&lt;/code&gt; profiler&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition to these, you can expect to see various &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html#optimizations&quot;&gt;performance optimizations&lt;/a&gt; and several &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html#improved-modules&quot;&gt;improvements to standard library&lt;/a&gt; modules, as well as many &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html#deprecated&quot;&gt;deprecations&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html#removed&quot;&gt;removals&lt;/a&gt; that have been planned for a long time.&lt;/p&gt;
&lt;p&gt;If you’re interested in reading a more detailed summary of the changes, then check out &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html&quot;&gt;What’s New In Python 3.12&lt;/a&gt; and the official &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/changelog.html&quot;&gt;Python 3.12 changelog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can also stay right here on the Real Python website and immerse yourself in the ultimate Python 3.12 experience by diving into one or all of the following resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tutorial&lt;/strong&gt;: Learn about the &lt;a href=&quot;https://realpython.com/python312-new-features/&quot;&gt;cool new features in Python 3.12&lt;/a&gt; through hands-on examples that you can follow in a step-by-step fashion.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Video Course&lt;/strong&gt;: Enjoy the &lt;a href=&quot;https://realpython.com/courses/new-features-python-312/&quot;&gt;companion video course&lt;/a&gt; that explores the new features in Python 3.12 in a more interactive and visual way.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Podcast&lt;/strong&gt;: Grab your favorite beverage, make yourself comfortable, and listen to our industry experts &lt;a href=&quot;https://realpython.com/podcasts/rpp/175/&quot;&gt;talk about the exciting updates and enhancements&lt;/a&gt; in Python 3.12.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Want more? Consider joining the discussion on the &lt;a href=&quot;https://realpython.com/community/&quot;&gt;Real Python Community&lt;/a&gt; chat, where you can ask questions, share insights, and connect with other Python enthusiasts eager to learn about Python 3.12. You can also learn from those who have already been using the Python 3.12 pre-release versions.&lt;/p&gt;
&lt;p&gt;If you prefer a live Q&amp;amp;A session with screen sharing, then we invite you to drop by a virtual &lt;a href=&quot;https://realpython.com/office-hours/&quot;&gt;Office Hours&lt;/a&gt; session hosted weekly by our team members. It’s a great opportunity to hang out with experts from the Python community and fellow Pythonistas like you. While there’s no fixed agenda, you can always ask questions specific to Python 3.12 or remain a silent participant by simply observing and learning from the discussions.&lt;/p&gt;
&lt;p&gt;As with every new release, upgrading to the latest Python version right away might not be feasible or desirable, especially for businesses where stability and backward compatibility are crucial. It usually takes time for library vendors to catch up. That said, a few notable libraries, including &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/pandas-python-explore-dataset/&quot;&gt;pandas&lt;/a&gt;, already rolled out &lt;a href=&quot;https://realpython.com/python-wheels/&quot;&gt;Python wheels&lt;/a&gt; targeting Python 3.12 on &lt;a href=&quot;https://pypi.org/&quot;&gt;PyPI&lt;/a&gt; back in September.&lt;/p&gt;
&lt;p&gt;Are you ready to take the leap into Python 3.12 yet?&lt;/p&gt;
&lt;h2 id=&quot;microsoft-excel-gets-the-python-editor&quot;&gt;Microsoft Excel Gets the Python Editor&lt;a class=&quot;headerlink&quot; href=&quot;#microsoft-excel-gets-the-python-editor&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Following the recent news from &lt;a href=&quot;https://techcommunity.microsoft.com/t5/excel-blog/announcing-python-in-excel-combining-the-power-of-python-and-the/ba-p/3893439&quot;&gt;Microsoft&lt;/a&gt; and &lt;a href=&quot;https://www.anaconda.com/excel&quot;&gt;Anaconda&lt;/a&gt; about their partnership to &lt;a href=&quot;https://realpython.com/python-news-august-2023/#python-makes-its-way-into-microsoft-excel&quot;&gt;bring Python into Excel&lt;/a&gt;, they don’t seem to be slowing down. Just this month, the Excel team at Microsoft &lt;a href=&quot;https://techcommunity.microsoft.com/t5/excel-blog/introducing-the-python-editor-from-excel-labs/ba-p/3928986&quot;&gt;announced&lt;/a&gt; the introduction of an experimental code editor for Python. While it’s only available as an extension at the moment, the editor may eventually become an integral part of the popular spreadsheet software.&lt;/p&gt;
&lt;p&gt;Today, you can enable the &lt;strong&gt;Python Editor&lt;/strong&gt; by installing the &lt;a href=&quot;https://www.microsoft.com/en-us/garage/profiles/excel-labs/&quot;&gt;Excel Labs&lt;/a&gt; add-in, which is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Microsoft_Garage&quot;&gt;Microsoft Garage&lt;/a&gt; project that started earlier this year to collect user feedback about experimental features in Excel. Primarily, this add-in provides an advanced formula-editing interface featuring syntax highlighting, auto-completion, inline error reporting, and more. Now, it also comes with a dedicated Python editor:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/python-editor-excel.56591a44ca89.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/python-editor-excel.56591a44ca89.png&quot; width=&quot;900&quot; height=&quot;999&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/python-editor-excel.56591a44ca89.png&amp;amp;w=225&amp;amp;sig=04d8c9c7adf828835b5cb047b0d2f26e842683ce 225w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/python-editor-excel.56591a44ca89.png&amp;amp;w=300&amp;amp;sig=44995373cd5f855f7c90720526addd2b8fc4b7de 300w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/python-editor-excel.56591a44ca89.png&amp;amp;w=450&amp;amp;sig=28d5d34cb78a9afa5d89f7f9c0938d38731eba63 450w, https://files.realpython.com/media/python-editor-excel.56591a44ca89.png 900w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Python Editor in Microsoft Excel&quot; data-asset=&quot;5467&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;&lt;a href=&quot;https://techcommunity.microsoft.com/t5/excel-blog/introducing-the-python-editor-from-excel-labs/ba-p/3928986&quot; target=&quot;_blank&quot;&gt;Image source&lt;/a&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Thanks to being built on top of the open-source &lt;a href=&quot;https://github.com/microsoft/monaco-editor&quot;&gt;Monaco Editor&lt;/a&gt;, which is also a core component of the familiar &lt;a href=&quot;https://realpython.com/python-development-visual-studio-code/&quot;&gt;Visual Studio Code&lt;/a&gt;, the Python Editor can run in your web browser. That’s essential for the ability to use the editor in the cloud-based &lt;a href=&quot;https://en.wikipedia.org/wiki/Microsoft_365&quot;&gt;Microsoft 365&lt;/a&gt; office suite.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-september-2023/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-september-2023/ »&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 #175: Exploring the New Features of Python 3.12</title>
      <id>https://realpython.com/podcasts/rpp/175/</id>
      <link href="https://realpython.com/podcasts/rpp/175/"/>
      <updated>2023-10-06T12:00:00+00:00</updated>
      <summary>Python 3.12 is here! Our regular guests, Geir Arne Hjelle and Christopher Trudeau, return to discuss the new version. Geir Arne coordinated a series of preview articles with several members of the Real Python team this year, and his showcase tutorial, &quot;Python 3.12: Cool New Features for You to Try,&quot; came out on October 2. Christopher&#x27;s video course was posted the next day, covering the topics from the article with visual examples of Python 3.12 in action.</summary>
      <content type="html">
        &lt;p&gt;Python 3.12 is here! Our regular guests, Geir Arne Hjelle and Christopher Trudeau, return to discuss the new version. Geir Arne coordinated a series of preview articles with several members of the Real Python team this year, and his showcase tutorial, &quot;Python 3.12: Cool New Features for You to Try,&quot; came out on October 2. Christopher&#x27;s video course was posted the next day, covering the topics from the article with visual examples of Python 3.12 in action.&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 tuple Data Type: A Deep Dive With Examples</title>
      <id>https://realpython.com/python-tuple/</id>
      <link href="https://realpython.com/python-tuple/"/>
      <updated>2023-10-04T14:00:00+00:00</updated>
      <summary>In Python, a tuple is a built-in data type that allows you to create immutable sequences of values. The values or items in a tuple can be of any type. This makes tuples pretty useful in those situations where you need to store heterogeneous data, like that in a database record, for example.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In Python, a &lt;strong&gt;&lt;code&gt;tuple&lt;/code&gt;&lt;/strong&gt; is a built-in data type that allows you to create &lt;strong&gt;immutable sequences&lt;/strong&gt; of values. The values or items in a tuple can be of any type. This makes tuples pretty useful in those situations where you need to store heterogeneous data, like that in a database record, for example.&lt;/p&gt;
&lt;p&gt;Through this tutorial, you’ll dive deep into Python tuples and get a solid understanding of their key features and use cases. This knowledge will allow you to write more efficient and reliable code by taking advantage of tuples.&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;Create&lt;/strong&gt; tuples in Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access&lt;/strong&gt; the items in an existing tuple&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unpack&lt;/strong&gt;, &lt;strong&gt;return&lt;/strong&gt;, &lt;strong&gt;copy&lt;/strong&gt;, and &lt;strong&gt;concatenate&lt;/strong&gt; tuples&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reverse&lt;/strong&gt;, &lt;strong&gt;sort&lt;/strong&gt;, and &lt;strong&gt;traverse&lt;/strong&gt; existing tuples&lt;/li&gt;
&lt;li&gt;Explore other &lt;strong&gt;features&lt;/strong&gt; and common &lt;strong&gt;gotchas&lt;/strong&gt; of tuples&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, you’ll explore some alternative tools that you can use to replace tuples and make your code more readable and explicit.&lt;/p&gt;
&lt;p&gt;To get the most out of this tutorial, you should have a good understanding of a few Python concepts, including &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt;. Familiarity with other built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data structures&lt;/a&gt;, especially &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;lists&lt;/a&gt;, is also a plus.&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-tuple-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-tuple-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 more readable code with tuples in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-started-with-pythons-tuple-data-type&quot;&gt;Getting Started With Python’s &lt;code&gt;tuple&lt;/code&gt; Data Type&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-pythons-tuple-data-type&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The built-in &lt;a href=&quot;https://realpython.com/python-lists-tuples/#python-tuples&quot;&gt;&lt;code&gt;tuple&lt;/code&gt;&lt;/a&gt; data type is probably the most elementary &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-sequence&quot;&gt;sequence&lt;/a&gt; available in Python. Tuples are &lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/#tuples&quot;&gt;immutable&lt;/a&gt; and can store a fixed number of items. For example, you can use tuples to represent &lt;a href=&quot;https://en.wikipedia.org/wiki/Cartesian_coordinate_system&quot;&gt;Cartesian&lt;/a&gt; coordinates &lt;code&gt;(x, y)&lt;/code&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/RGB_color_model&quot;&gt;RGB&lt;/a&gt; colors &lt;code&gt;(red, green, blue)&lt;/code&gt;, records in a database table &lt;code&gt;(name, age, job)&lt;/code&gt;, and many other sequences of values.&lt;/p&gt;
&lt;p&gt;In all these use cases, the number of elements in the underlying tuple is &lt;em&gt;fixed&lt;/em&gt;, and the items are &lt;em&gt;unchangeable&lt;/em&gt;. You may find several situations where these two characteristics are desirable. For example, consider the RGB color example:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;red&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;mi&quot;&gt;255&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;p&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;/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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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’ve defined &lt;code&gt;red&lt;/code&gt;, then you won’t need to add or change any components. Why? If you change the value of one component, then you won’t have a pure red color anymore, and your variable name will be misleading. If you add a new component, then your color won’t be an RGB color. So, tuples are perfect for representing this type of object.&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; Throughout this tutorial, you’ll find the terms &lt;strong&gt;items&lt;/strong&gt;, &lt;strong&gt;elements&lt;/strong&gt;, and &lt;strong&gt;values&lt;/strong&gt; used interchangeably to refer to the objects stored in a tuple.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Some of the most relevant characteristics of &lt;code&gt;tuple&lt;/code&gt; objects include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ordered&lt;/strong&gt;: They contain elements that are sequentially arranged according to their specific insertion order.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lightweight&lt;/strong&gt;: They consume relatively small amounts of memory compared to other sequences like lists.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Indexable through a zero-based index&lt;/strong&gt;: They allow you to access their elements by integer indices that start from zero.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Immutable&lt;/strong&gt;: They don’t support in-place mutations or changes to their contained elements. They don’t support growing or shrinking operations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Heterogeneous&lt;/strong&gt;: They can store objects of different data types and domains, including mutable objects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nestable&lt;/strong&gt;: They can contain other tuples, so you can have tuples of tuples.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Iterable&lt;/strong&gt;: They support iteration, so you can traverse them using a loop or comprehension while you perform operations with each of their elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sliceable&lt;/strong&gt;: They support slicing operations, meaning that you can extract a series of elements from a tuple.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combinable&lt;/strong&gt;: They support concatenation operations, so you can combine two or more tuples using the concatenation operators, which creates a new tuple.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hashable&lt;/strong&gt;: They can work as keys in &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt; when all the tuple items are immutable.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tuples are sequences of objects. They’re commonly called &lt;strong&gt;containers&lt;/strong&gt; or &lt;strong&gt;collections&lt;/strong&gt; because a single tuple can contain or collect an arbitrary number of other objects.&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; In Python, tuples support several operations that are common to other sequence types, such as lists, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-range/&quot;&gt;ranges&lt;/a&gt;. These operations are known as &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#common-sequence-operations&quot;&gt;common sequence operations&lt;/a&gt;. Throughout this tutorial, you’ll learn about several operations that fall into this category.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In Python, tuples are ordered, which means that they keep their elements in the original insertion order:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;record&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;s2&quot;&gt;&quot;John&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Python Developer&quot;&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;n&quot;&gt;record&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;(&#x27;John&#x27;, 35, &#x27;Python Developer&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 items in this tuple are objects of different data types representing a record of data from a database table. If you access the tuple object, then you’ll see that the data items keep the same original insertion order. This order remains unchanged during the tuple’s lifetime.&lt;/p&gt;
&lt;p&gt;You can access individual objects in a tuple by position, or index. These indices start from zero:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;record&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;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;John&#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;record&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;35&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;record&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;&#x27;Python Developer&#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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;Positions are numbered from zero to the length of the tuple minus one. The element at index &lt;code&gt;0&lt;/code&gt; is the first element in the tuple, the element at index &lt;code&gt;1&lt;/code&gt; is the second, and so on.&lt;/p&gt;
&lt;p&gt;Cool! You’ve had a first glance at tuples. It’s time to dive deeper into all of the above characteristics of tuples and more. To kick things off, you’ll start by learning the different ways to create tuples in Python.&lt;/p&gt;
&lt;h2 id=&quot;constructing-tuples-in-python&quot;&gt;Constructing Tuples in Python&lt;a class=&quot;headerlink&quot; href=&quot;#constructing-tuples-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-tuple/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-tuple/ »&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>What&#x27;s New in Python 3.12</title>
      <id>https://realpython.com/courses/new-features-python-312/</id>
      <link href="https://realpython.com/courses/new-features-python-312/"/>
      <updated>2023-10-03T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll explore the new features that Python 3.12 brings to the table. These include improved f-strings, better error messages, changes to CPython internals, additions to static typing, and more.</summary>
      <content type="html">
        &lt;p&gt;It&amp;rsquo;s that time of year again, time for a new release of Python. Although &lt;strong&gt;Python 3.12&lt;/strong&gt;
mostly focuses on internal improvements, there&amp;rsquo;s a little something for
everyone. You can read up on all the new features by checking out the &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html&quot;&gt;changelog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn about the following changes:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Improvements to &lt;strong&gt;f-strings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;More &lt;strong&gt;did-you-mean error messages&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New features&lt;/strong&gt; in the standard library&lt;/li&gt;
&lt;li&gt;Additions to &lt;strong&gt;static typing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Changes to the &lt;strong&gt;CPython interpreter&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll explore these changes and see how this new version of
Python can work for you.&lt;/p&gt;
&lt;p&gt;If you want to try any of the examples in this video course, then you&amp;rsquo;ll need to use Python 3.12. The &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;Python 3 Installation &amp;amp; Setup Guide&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-pre-release/&quot;&gt;How Can You Install a Pre-Release Version of Python?&lt;/a&gt; walk you through several options for adding a new version of Python to your system.&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 3.12: Cool New Features for You to Try</title>
      <id>https://realpython.com/python312-new-features/</id>
      <link href="https://realpython.com/python312-new-features/"/>
      <updated>2023-10-02T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about the new features in Python 3.12. You&#x27;ll explore how the new release extends the better error messages and faster code execution found in the previous version, and you&#x27;ll try out the improvements to f-strings and type variable syntax.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.python.org/downloads/release/python-3120/&quot;&gt;Python 3.12&lt;/a&gt; was published on &lt;a href=&quot;https://peps.python.org/pep-0693/&quot;&gt;October 2, 2023&lt;/a&gt;. As usual, the new version comes out in October after lots of effort by volunteers worldwide.&lt;/p&gt;
&lt;p&gt;The new version comes with several new features and improvements that you’ll explore in this tutorial. You can also dive into the &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html&quot;&gt;documentation&lt;/a&gt; to see a complete list of all changes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn about new features and improvements, like:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Better &lt;strong&gt;error messages&lt;/strong&gt; with helpful suggestions and guidance&lt;/li&gt;
&lt;li&gt;More expressive &lt;strong&gt;f-strings&lt;/strong&gt; that are backed by Python’s PEG parser&lt;/li&gt;
&lt;li&gt;Optimizations, including &lt;strong&gt;inlined comprehensions&lt;/strong&gt;, for a faster Python&lt;/li&gt;
&lt;li&gt;A new syntax for &lt;strong&gt;type variables&lt;/strong&gt; that you use to annotate generics&lt;/li&gt;
&lt;li&gt;Support for the powerful &lt;strong&gt;&lt;code&gt;perf&lt;/code&gt; profiler&lt;/strong&gt; on Linux&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want to try any of the examples in this tutorial, then you’ll need to use Python 3.12. The tutorials &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;Python 3 Installation &amp;amp; Setup Guide&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-pre-release/&quot;&gt;How Can You Install a Pre-Release Version of Python?&lt;/a&gt; walk you through several options for adding a new version of Python to your system.&lt;/p&gt;
&lt;p&gt;In addition to learning more about the new features coming to the language, you’ll also get some &lt;a href=&quot;#so-should-you-upgrade-to-python-312&quot;&gt;advice&lt;/a&gt; about what to consider before upgrading to the new version. Click the link below to download code examples demonstrating the new capabilities of Python 3.12:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-312-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-312-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your sample code&lt;/a&gt; for a sneak peek at Python 3.12, coming in October 2023.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;improved-error-messages&quot;&gt;Improved Error Messages&lt;a class=&quot;headerlink&quot; href=&quot;#improved-error-messages&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python is usually recognized as a good beginner language, and it’s lauded for its readable syntax. One area where it’s become even more user-friendly lately is &lt;strong&gt;error messages&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In &lt;a href=&quot;https://realpython.com/python310-new-features/&quot;&gt;Python 3.10&lt;/a&gt;, many error messages—especially for syntax errors—got &lt;a href=&quot;https://realpython.com/python310-new-features/#better-error-messages&quot;&gt;more informative and precise&lt;/a&gt;. Similarly, &lt;a href=&quot;https://realpython.com/python311-new-features/&quot;&gt;Python 3.11&lt;/a&gt; added &lt;a href=&quot;https://realpython.com/python311-error-messages/&quot;&gt;more information in tracebacks&lt;/a&gt;, making it more convenient to pinpoint offending code.&lt;/p&gt;
&lt;p&gt;The latest version of Python continues the work of improving your developer experience by providing better error messages. In particular, several common error messages now come with helpful suggestions. In the rest of this section, you’ll explore the new and improved messages.&lt;/p&gt;
&lt;p&gt;Several of the improvements relate to importing modules. In the next three examples, you try to work with π by importing &lt;code&gt;pi&lt;/code&gt; from &lt;code&gt;math&lt;/code&gt;. In each example, you’ll see one of the new suggestions in Python 3.12. Here’s the first one:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;math&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt;
&lt;span class=&quot;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gr&quot;&gt;NameError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;name &#x27;math&#x27; is not defined. Did you forget to import &#x27;math&#x27;?&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;When you use &lt;code&gt;math&lt;/code&gt; without importing it first, you’ll get a traditional &lt;code&gt;NameError&lt;/code&gt;. Additionally, the parser helpfully reminds you that you need to import &lt;code&gt;math&lt;/code&gt; before accessing it.&lt;/p&gt;
&lt;p&gt;The reminder about remembering to import modules only triggers for standard library modules. For these error messages, Python 3.12 doesn’t track third-party packages that you’ve installed.&lt;/p&gt;
&lt;p&gt;It’s possible to import specific names from a module using a &lt;a href=&quot;https://realpython.com/python-modules-packages/#from-module_name-import-names&quot;&gt;&lt;code&gt;from&lt;/code&gt;-&lt;code&gt;import&lt;/code&gt;&lt;/a&gt; statement. If you happen to switch the order of the keywords, you’ll now get a friendly nudge towards the correct syntax:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;pi&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;math&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  ...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    import pi from math&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    ^^^^^^^^^^^^^^^^^^^&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;SyntaxError: Did you mean to use &#x27;from ... import ...&#x27; instead?&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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, you tried to import &lt;code&gt;pi&lt;/code&gt; from &lt;code&gt;math&lt;/code&gt;, but Python needs you to reorder the statement and put &lt;code&gt;from&lt;/code&gt; before &lt;code&gt;import&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To see a third new error message, check out what happens if you import &lt;code&gt;py&lt;/code&gt; and not &lt;code&gt;pi&lt;/code&gt; from &lt;code&gt;math&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;math&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;py&lt;/span&gt;
&lt;span class=&quot;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gr&quot;&gt;ImportError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;cannot import name &#x27;py&#x27; from &#x27;math&#x27;. Did you mean: &#x27;pi&#x27;?&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;There’s no &lt;code&gt;py&lt;/code&gt; name in &lt;code&gt;math&lt;/code&gt;, so you get an &lt;code&gt;ImportError&lt;/code&gt;. The parser suggests that you probably meant &lt;code&gt;pi&lt;/code&gt; instead of &lt;code&gt;py&lt;/code&gt;. Python 3.10 introduced a similar &lt;a href=&quot;https://realpython.com/python310-new-features/#better-error-messages&quot;&gt;suggestion feature&lt;/a&gt;, where Python looks for similar names. What’s new in Python 3.12 is the ability to do this while importing.&lt;/p&gt;
&lt;p&gt;In addition to these three improvements related to imports, there’s a final improvement concerning methods defined inside classes. Have a look at the following implementation of a &lt;code&gt;Circle&lt;/code&gt; class:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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 python highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# shapes.py&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;math&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Circle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fm&quot;&gt;__init__&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;n&quot;&gt;radius&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;radius&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;radius&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;area&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;hll&quot;&gt;&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;radius&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&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 you wrongly refer to &lt;code&gt;radius&lt;/code&gt; instead of &lt;code&gt;self.radius&lt;/code&gt; inside &lt;code&gt;.area()&lt;/code&gt;. This will cause an error when you call the method:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;shapes&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Circle&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;Circle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;area&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;
&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;...&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;/home/realpython/shapes.py&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;, in &lt;span class=&quot;n&quot;&gt;area&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;radius&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;w&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;pm&quot;&gt;^^^^^^&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gr&quot;&gt;NameError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;name &#x27;radius&#x27; is not defined. Did you mean: &#x27;self.radius&#x27;?&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/static/icons.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python312-new-features/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python312-new-features/ »&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 #174: Considering ChatGPT&#x27;s Technical Review of a Programming Book</title>
      <id>https://realpython.com/podcasts/rpp/174/</id>
      <link href="https://realpython.com/podcasts/rpp/174/"/>
      <updated>2023-09-29T12:00:00+00:00</updated>
      <summary>What can you learn from feeding an entire book on Python programming into ChatGPT-4 and asking it to provide a technical review? What are the potential pitfalls of using an LLM as a learning tool? This week on the show, author Al Sweigart talks about his recent experiments using ChatGPT and Python.</summary>
      <content type="html">
        &lt;p&gt;What can you learn from feeding an entire book on Python programming into ChatGPT-4 and asking it to provide a technical review? What are the potential pitfalls of using an LLM as a learning tool? This week on the show, author Al Sweigart talks about his recent experiments using ChatGPT and 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 3.12 Preview: Static Typing Improvements</title>
      <id>https://realpython.com/python312-typing/</id>
      <link href="https://realpython.com/python312-typing/"/>
      <updated>2023-09-27T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll preview the new static typing features in Python 3.12. You&#x27;ll learn about the new syntax for type variables, making generics simpler to define. You&#x27;ll also see how @override lets you model inheritance and how you use typed dictionaries to annotate variable keyword arguments.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s support for static typing gradually improves with each new release of Python. The core features were in place in &lt;a href=&quot;https://docs.python.org/3/whatsnew/3.5.html&quot;&gt;Python 3.5&lt;/a&gt;. Since then, there’ve been many tweaks and improvements to the &lt;strong&gt;type hinting system&lt;/strong&gt;. This evolution continues in Python 3.12, which, in particular, simplifies the typing of generics.&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;Use &lt;strong&gt;type variables&lt;/strong&gt; in Python to annotate generic classes and functions&lt;/li&gt;
&lt;li&gt;Explore the &lt;strong&gt;new syntax&lt;/strong&gt; for type hinting type variables&lt;/li&gt;
&lt;li&gt;Model inheritance with the new &lt;strong&gt;&lt;code&gt;@override&lt;/code&gt; decorator&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Annotate &lt;code&gt;**kwargs&lt;/code&gt; more precisely&lt;/strong&gt; with typed dictionaries&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This won’t be an introduction to using type hints in Python. If you want to review the background that you’ll need for this tutorial, then have a look at &lt;a href=&quot;https://realpython.com/python-type-checking/&quot;&gt;Python Type Checking&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You’ll find many other new features, improvements, and optimizations in Python 3.12. The most relevant ones include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-error-messages/&quot;&gt;Ever better error messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-perf-profiler/&quot;&gt;Support for the Linux &lt;code&gt;perf&lt;/code&gt; profiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-f-strings/&quot;&gt;More powerful f-strings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-subinterpreters/&quot;&gt;Support for subinterpreters&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Go ahead and check out &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html&quot;&gt;what’s new&lt;/a&gt; in the changelog for more details on these and other features or listen to our comprehensive &lt;a href=&quot;https://realpython.com/podcasts/rpp/175/&quot;&gt;podcast episode&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;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-312-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-312-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your sample code&lt;/a&gt; for a sneak peek at Python 3.12, coming in October 2023.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;recap-type-variable-syntax-before-python-312&quot;&gt;Recap Type Variable Syntax Before Python 3.12&lt;a class=&quot;headerlink&quot; href=&quot;#recap-type-variable-syntax-before-python-312&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Type variables have been a part of Python’s static typing system since its introduction in Python 3.5. &lt;a href=&quot;https://peps.python.org/pep-0484/&quot;&gt;PEP 484&lt;/a&gt; introduced type hints to the language, and type variables and generics play an important role in that document. In this section, you’ll dive into how you’ve used type variables so far. This’ll give you the necessary background to appreciate the new syntax that you’ll learn about later.&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;generic type&lt;/strong&gt; is a type parametrized by another type. Typical examples include a &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;list&lt;/a&gt; of integers and a tuple consisting of a float, a string, and another float. You use square brackets to parametrize generics in Python. You can write the two examples above as &lt;code&gt;list[int]&lt;/code&gt; and &lt;code&gt;tuple[float, str, float]&lt;/code&gt;, respectively.&lt;/p&gt;
&lt;p&gt;In addition to using built-in generic types, you can define your own &lt;a href=&quot;https://mypy.readthedocs.io/en/stable/generics.html&quot;&gt;generic&lt;/a&gt; classes. In the following example, you implement a generic &lt;a href=&quot;https://realpython.com/queue-in-python/&quot;&gt;queue&lt;/a&gt; based on &lt;a href=&quot;https://realpython.com/python-deque/&quot;&gt;&lt;code&gt;deque&lt;/code&gt;&lt;/a&gt; in the standard library:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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 python highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# generic_queue.py&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;collections&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deque&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;typing&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Generic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TypeVar&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TypeVar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;T&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;Queue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Generic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&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;fm&quot;&gt;__init__&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;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deque&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deque&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;push&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;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&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;pop&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;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T&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;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;popleft&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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 is a first-in, first-out (&lt;a href=&quot;https://realpython.com/queue-in-python/#queue-first-in-first-out-fifo&quot;&gt;FIFO&lt;/a&gt;) queue. It represents the kind of lines that you’ll find yourself in at stores, where the first person into the queue is also the first one to leave the queue. Before looking closer at the code, and in particular at the type hints, play a little with the class:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 python repl 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;generic_queue&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Queue&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;queue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]()&lt;/span&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;queue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&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;n&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;queue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elements&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;deque([3, 12])&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;queue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pop&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;You can use &lt;code&gt;.push()&lt;/code&gt; to add elements to the queue and &lt;code&gt;.pop()&lt;/code&gt; to remove elements from the queue. Note that when you called the &lt;code&gt;Queue()&lt;/code&gt; &lt;a href=&quot;https://realpython.com/python-class-constructor/&quot;&gt;constructor&lt;/a&gt;, you included &lt;code&gt;[int]&lt;/code&gt;. This isn’t necessary, but it tells the type checker that you expect the queue to only contain integer elements.&lt;/p&gt;
&lt;p&gt;Normally, using square brackets like you did in &lt;code&gt;Queue[int]()&lt;/code&gt; isn’t valid Python syntax. You can use square brackets with &lt;code&gt;Queue&lt;/code&gt;, however, because you defined &lt;code&gt;Queue&lt;/code&gt; as a generic class by inheriting from &lt;code&gt;Generic&lt;/code&gt;. How does the rest of your class use this &lt;code&gt;int&lt;/code&gt; parameter?&lt;/p&gt;
&lt;p&gt;To answer that question, you need to look at &lt;code&gt;T&lt;/code&gt;, which is a &lt;strong&gt;type variable&lt;/strong&gt;. A type variable is a special variable that can stand in for any type. However, during type checking, the type of &lt;code&gt;T&lt;/code&gt; will be fixed.&lt;/p&gt;
&lt;p&gt;In your &lt;code&gt;Queue[int]&lt;/code&gt; example, &lt;code&gt;T&lt;/code&gt; will be &lt;code&gt;int&lt;/code&gt; in all annotations on the class. You could also instantiate &lt;code&gt;Queue[str]&lt;/code&gt;, where &lt;code&gt;T&lt;/code&gt; would represent &lt;code&gt;str&lt;/code&gt; everywhere. This would then be a queue with string elements.&lt;/p&gt;
&lt;p&gt;If you look back at the source code of &lt;code&gt;Queue&lt;/code&gt;, then you’ll see that &lt;code&gt;.pop()&lt;/code&gt; returns an object of type &lt;code&gt;T&lt;/code&gt;. In your special integer queue, the static type checker will make sure that &lt;code&gt;.pop()&lt;/code&gt; returns an integer.&lt;/p&gt;
&lt;p&gt;Speaking of static type checkers, how do you actually check the types in your code? Type annotations are mostly ignored during runtime. Instead, you need to install a separate type checker and run it explicitly on your code.&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; In this tutorial, you’ll use &lt;a href=&quot;https://microsoft.github.io/pyright/&quot;&gt;Pyright&lt;/a&gt; as your type checker. You can install Pyright from &lt;a href=&quot;https://pypi.org/project/pyright/&quot;&gt;PyPI&lt;/a&gt; using &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;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 sh 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;pyright
&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;If you’re using &lt;a href=&quot;https://realpython.com/advanced-visual-studio-code-python/&quot;&gt;Visual Studio Code&lt;/a&gt;, then you can use Pyright inside the editor through the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance&quot;&gt;Pylance&lt;/a&gt; extension. You may need to activate it by setting the &lt;em&gt;Python › Analysis: Type Checking Mode&lt;/em&gt; option in your settings.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you install Pyright, then you can use it to type check your code:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&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.4bb4395d5bcd.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 sh 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;pyright&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;generic_queue.py
&lt;span class=&quot;go&quot;&gt;0 errors, 0 warnings, 0 informations&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.4bb4395d5bcd.svg#light--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.4bb4395d5bcd.svg#v4--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;To see an example of the kinds of errors that Pyright can detect, add the following lines to your generic queue implementation:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python312-typing/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python312-typing/ »&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: Conditional Logic and Control Flow</title>
      <id>https://realpython.com/courses/conditional-logic-control-flow-exercises/</id>
      <link href="https://realpython.com/courses/conditional-logic-control-flow-exercises/"/>
      <updated>2023-09-26T14:00:00+00:00</updated>
      <summary>In this Python Basics Exercises course, you&#x27;ll review how to use conditional logic to write programs that perform different actions based on different conditions. Paired with functions and loops, conditional logic allows you to write complex programs that can handle many different situations.</summary>
      <content type="html">
        &lt;p&gt;In &lt;a href=&quot;https://realpython.com/courses/basics-conditional-logic-control-flow/&quot;&gt;Python Basics: Conditional Logic and Control Flow&lt;/a&gt;, you learned that much of the Python code you&amp;rsquo;ll write is unconditional. That is, the code doesn&amp;rsquo;t make any choices. Every line of code is executed in the order that it&amp;rsquo;s written or in the order that functions are called, with possible repetitions inside loops.&lt;/p&gt;
&lt;p&gt;In this course, you&amp;rsquo;ll revisit how to use conditional logic to write programs that perform different actions based on different conditions. Paired with functions and loops, conditional logic allows you to write complex programs that can handle many different situations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll use the following:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Boolean comparators&lt;/strong&gt;: &lt;code&gt;==&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logical operators&lt;/strong&gt;: &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt;, &lt;code&gt;not&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conditional logic&lt;/strong&gt;: &lt;code&gt;if&lt;/code&gt; &amp;hellip; &lt;code&gt;elif&lt;/code&gt; &amp;hellip; &lt;code&gt;else&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exception handling&lt;/strong&gt;: &lt;code&gt;try&lt;/code&gt; &amp;hellip; &lt;code&gt;except&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loops&lt;/strong&gt;: &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Control flow statements&lt;/strong&gt;: &lt;code&gt;break&lt;/code&gt;, &lt;code&gt;continue&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ultimately, you&amp;rsquo;ll bring all of your knowledge together to build a &lt;strong&gt;text-based role-playing game&lt;/strong&gt;. Along the way, you&amp;rsquo;ll also get some insight into how to tackle coding challenges in general, which can be a great way to level up as a developer.&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 #173: Getting Involved in Open Source &amp; Generating QR Codes With Python</title>
      <id>https://realpython.com/podcasts/rpp/173/</id>
      <link href="https://realpython.com/podcasts/rpp/173/"/>
      <updated>2023-09-22T12:00:00+00:00</updated>
      <summary>Have you thought about contributing to an open-source Python project? What are possible entry points for intermediate developers? 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;Have you thought about contributing to an open-source Python project? What are possible entry points for intermediate developers? 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>Design and Guidance: Object-Oriented Programming in Python</title>
      <id>https://realpython.com/courses/solid-principles-python/</id>
      <link href="https://realpython.com/courses/solid-principles-python/"/>
      <updated>2023-09-19T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about the SOLID principles, which are five well-established standards for improving your object-oriented design in Python. By applying these principles, you can create object-oriented code that is more maintainable, extensible, scalable, and testable.</summary>
      <content type="html">
        &lt;p&gt;Writing good object-oriented code is about more than just how to write the
syntax. Knowing when and when not to use it, as well as guiding principles
behind &lt;strong&gt;object-oriented design&lt;/strong&gt; will help you write better code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The objected-oriented approach in &lt;strong&gt;Python vs other languages&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Cases in which you &lt;strong&gt;shouldn&amp;rsquo;t use&lt;/strong&gt; classes in Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alternatives to inheritance&lt;/strong&gt; in structuring your code&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;SOLID principles&lt;/strong&gt; for improving your code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SOLID is an acronym for five principles that you should use when thinking about
object-oriented code. The principles are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Single-Responsibility Principle (SRP)&lt;/li&gt;
&lt;li&gt;The Open-Closed Principle (OCP)&lt;/li&gt;
&lt;li&gt;The Liskov Substitution Principle (LSP)&lt;/li&gt;
&lt;li&gt;The Interface Segregation Principle (ISP)&lt;/li&gt;
&lt;li&gt;The Dependency Inversion Principle (DIP)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This course is the third in a three-part series. &lt;a href=&quot;https://realpython.com/courses/python-class-object/&quot;&gt;Part one&lt;/a&gt; is an introduction
to class syntax, where you learn how to write a class and use its attributes and
methods. &lt;a href=&quot;https://realpython.com/courses/python-class-inheritance/&quot;&gt;Part two&lt;/a&gt; is about inheritance and class internals.&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 #172: Measuring Multiple Facets of Python Performance With Scalene</title>
      <id>https://realpython.com/podcasts/rpp/172/</id>
      <link href="https://realpython.com/podcasts/rpp/172/"/>
      <updated>2023-09-15T12:00:00+00:00</updated>
      <summary>When choosing a tool for profiling Python code performance, should it focus on the CPU, GPU, memory, or individual lines of code? What if it looked at all those factors and didn&#x27;t alter code performance while measuring it? This week on the show, we talk about Scalene with Emery Berger, Professor of Computer Science at the University of Massachusetts Amherst.</summary>
      <content type="html">
        &lt;p&gt;When choosing a tool for profiling Python code performance, should it focus on the CPU, GPU, memory, or individual lines of code? What if it looked at all those factors and didn&#x27;t alter code performance while measuring it? This week on the show, we talk about Scalene with Emery Berger, Professor of Computer Science at the University of Massachusetts Amherst.&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>Inheritance and Internals: Object-Oriented Programming in Python</title>
      <id>https://realpython.com/courses/python-class-inheritance/</id>
      <link href="https://realpython.com/courses/python-class-inheritance/"/>
      <updated>2023-09-12T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about the various types of inheritance that you can use to write object-oriented code in Python. These include class inheritance, multilevel inheritance, and multiple inheritance, along with special methods and abstract base classes.</summary>
      <content type="html">
        &lt;p&gt;Python includes mechanisms for writing object-oriented code where the
data and operations on that data are structured together. The &lt;strong&gt;&lt;code&gt;class&lt;/code&gt; keyword&lt;/strong&gt;
is how you create these structures in Python. The definition of a class can be
based on other classes, allowing the creation of hierarchical structures and
promoting code reuse. This mechanism is known as inheritance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Basic &lt;strong&gt;class inheritance&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-level inheritance&lt;/strong&gt;, or classes that inherit from classes&lt;/li&gt;
&lt;li&gt;Classes that inherit directly from more than one class, or &lt;strong&gt;multiple inheritance&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Special methods&lt;/strong&gt; that you can use when writing classes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Abstract base classes&lt;/strong&gt; for classes that you don&amp;rsquo;t want to fully implement yet&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This course is the second in a three-part series. &lt;a href=&quot;https://realpython.com/courses/python-class-object/&quot;&gt;Part one&lt;/a&gt; is an introduction
to class syntax, teaching you how to write a class and use its attributes and
methods. Part three dives deeper into the philosophy behind writing good
object-oriented code.&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 #171: Making Each Line of Code Efficient &amp; Python In Excel</title>
      <id>https://realpython.com/podcasts/rpp/171/</id>
      <link href="https://realpython.com/podcasts/rpp/171/"/>
      <updated>2023-09-08T12:00:00+00:00</updated>
      <summary>Are you writing efficient Python with as few lines of code as possible? Are you familiar with the many built-in language features that will simplify your code and make it more Pythonic? 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;Are you writing efficient Python with as few lines of code as possible? Are you familiar with the many built-in language features that will simplify your code and make it more Pythonic? 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>Class Concepts: Object-Oriented Programming in Python</title>
      <id>https://realpython.com/courses/python-class-object/</id>
      <link href="https://realpython.com/courses/python-class-object/"/>
      <updated>2023-09-05T12:00:00+00:00</updated>
      <summary>Python uses object-oriented programming to group data and associated operations together into classes. In this video course, you&#x27;ll learn how to write object-oriented code with classes, attributes, and methods.</summary>
      <content type="html">
        &lt;p&gt;Python includes mechanisms for doing &lt;strong&gt;object-oriented programming&lt;/strong&gt;, where the
data and operations on that data are structured together. The &lt;code&gt;class&lt;/code&gt; keyword
is how you create these structures in Python. &lt;strong&gt;Attributes&lt;/strong&gt; are the data
values, and &lt;strong&gt;methods&lt;/strong&gt; are the function-like operations that you can perform 
on classes. In this course, you&amp;rsquo;ll explore writing code using &lt;code&gt;class&lt;/code&gt; and its 
associated attributes and methods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why you write &lt;strong&gt;object-oriented code&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to write a &lt;strong&gt;class&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;attributes&lt;/strong&gt; and &lt;strong&gt;methods&lt;/strong&gt; are&lt;/li&gt;
&lt;li&gt;How to use the &lt;strong&gt;descriptor protocol&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This course is the first in a three-part series. Part two covers how to
write reusable hierarchies of classes using inheritance, while part three
dives deeper into the philosophy behind writing good object-oriented code.&lt;/p&gt;
&lt;div class=&quot;container border rounded my-4&quot;&gt;
  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;i class=&quot;fa fa-cloud-download mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
&lt;strong&gt;Download&lt;/strong&gt;&lt;/p&gt;
      &lt;a class=&quot;stretched-link&quot; href=&quot;/courses/python-class-object/downloads/python-class-object-code/&quot; target=&quot;_blank&quot;&gt;&lt;p class=&quot;h2 my-0 h3&quot;&gt;Sample Code (.zip)&lt;/p&gt;&lt;/a&gt;
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;5.2 KB&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;container border rounded my-4&quot;&gt;
  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;i class=&quot;fa fa-cloud-download mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
&lt;strong&gt;Download&lt;/strong&gt;&lt;/p&gt;
      &lt;a class=&quot;stretched-link&quot; href=&quot;/courses/python-class-object/downloads/python-class-object-slides/&quot; target=&quot;_blank&quot;&gt;&lt;p class=&quot;h2 my-0 h3&quot;&gt;Course Slides (.pdf)&lt;/p&gt;&lt;/a&gt;
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;1013.9 KB&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&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 #170: Finding the Right Coding Font for Programming in Python</title>
      <id>https://realpython.com/podcasts/rpp/170/</id>
      <link href="https://realpython.com/podcasts/rpp/170/"/>
      <updated>2023-09-01T12:00:00+00:00</updated>
      <summary>What should you consider when picking a font for coding in Python? What characters and their respective glyphs should you check before making your decision? This week on the show, we talk with Real Python author and core team member Philipp Acsany about his recent article, Choosing the Best Coding Font for Programming.</summary>
      <content type="html">
        &lt;p&gt;What should you consider when picking a font for coding in Python? What characters and their respective glyphs should you check before making your decision? This week on the show, we talk with Real Python author and core team member Philipp Acsany about his recent article, Choosing the Best Coding Font for Programming.&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 Python Wordle Clone With Rich</title>
      <id>https://realpython.com/courses/python-wordle-clone/</id>
      <link href="https://realpython.com/courses/python-wordle-clone/"/>
      <updated>2023-08-29T14:00:00+00:00</updated>
      <summary>In this step-by-step project, you&#x27;ll build your own Wordle clone with Python. Your game will run in the terminal, and you&#x27;ll use Rich to ensure your word-guessing app looks good. Learn how to build a command-line application from scratch and then challenge your friends to a wordly competition!</summary>
      <content type="html">
        &lt;p&gt;In this video course, you&amp;rsquo;ll build your own &lt;strong&gt;Wordle clone&lt;/strong&gt; for the terminal. Since Josh Wardle launched &lt;a href=&quot;https://en.wikipedia.org/wiki/Wordle&quot;&gt;Wordle&lt;/a&gt; in October 2021, millions of people have played it. While you can play the original game on the Web, you&amp;rsquo;ll create your version as a command-line application and then use the &lt;strong&gt;Rich library&lt;/strong&gt; to make it look good.&lt;/p&gt;
&lt;p&gt;As you follow along in this step-by-step project, you&amp;rsquo;ll practice how to set up a simple prototype game before iteratively developing it into a solid application.&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;Build out a command-line application from a &lt;strong&gt;prototype&lt;/strong&gt; to a &lt;strong&gt;polished game&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Read and &lt;strong&gt;validate user input&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use Rich&amp;rsquo;s console to create an &lt;strong&gt;attractive user interface&lt;/strong&gt; in the terminal&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Organize your code&lt;/strong&gt; into functions&lt;/li&gt;
&lt;li&gt;Provide your users with &lt;strong&gt;actionable feedback&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;rsquo;ll create &lt;strong&gt;Wyrdl&lt;/strong&gt;, your own Wordle clone in Python. This project is for anyone getting comfortable with Python who wants to build a terminal application from the ground up. Throughout the course, you&amp;rsquo;ll build your code step-by-step while focusing on having a game that you can play from the start.&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 #169: Improving Classification Models With XGBoost</title>
      <id>https://realpython.com/podcasts/rpp/169/</id>
      <link href="https://realpython.com/podcasts/rpp/169/"/>
      <updated>2023-08-25T12:00:00+00:00</updated>
      <summary>How can you improve a classification model while avoiding overfitting? Once you have a model, what tools can you use to explain it to others? This week on the show, we talk with author and Python trainer Matt Harrison about his new book Effective XGBoost: Tuning, Understanding, and Deploying Classification Models.</summary>
      <content type="html">
        &lt;p&gt;How can you improve a classification model while avoiding overfitting? Once you have a model, what tools can you use to explain it to others? This week on the show, we talk with author and Python trainer Matt Harrison about his new book Effective XGBoost: Tuning, Understanding, and Deploying Classification Models.&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>
