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

  
    <entry>
      <title>Python 3.11: Cool New Features for You to Try</title>
      <id>https://realpython.com/python311-new-features/</id>
      <link href="https://realpython.com/python311-new-features/"/>
      <updated>2022-10-24T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll explore what Python 3.11 brings to the table. You&#x27;ll learn how Python 3.11 is the fastest and most user-friendly version of CPython yet, and learn about improvements to the typing system and to the asynchronous features of Python.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://www.python.org/downloads/release/python-3110/&quot;&gt;Python 3.11&lt;/a&gt; was published on &lt;a href=&quot;https://peps.python.org/pep-0664/&quot;&gt;October 24, 2022&lt;/a&gt;. This latest version of Python is faster and more user-friendly. After seventeen months of development, it’s now ready for prime-time use.&lt;/p&gt;
&lt;p&gt;As in every version, Python 3.11 comes with lots of improvements and changes. You can see a list of all of them in the &lt;a href=&quot;https://docs.python.org/3.11/whatsnew/3.11.html&quot;&gt;documentation&lt;/a&gt;. Here, you’ll explore the coolest and most impactful new features.&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 more informative tracebacks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Faster code execution&lt;/strong&gt; due to considerable effort in the &lt;strong&gt;Faster CPython&lt;/strong&gt; project&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Task and exception groups&lt;/strong&gt; that simplify working with asynchronous code&lt;/li&gt;
&lt;li&gt;Several new typing features that improve Python’s &lt;strong&gt;static typing support&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Native &lt;strong&gt;TOML support&lt;/strong&gt; for working with configuration files&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.11. 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;p&gt;In addition to learning more about the new features coming to the language, you’ll also get some advice 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.11:&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-311-examples/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-311-examples&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download free sample code&lt;/a&gt; that demonstrates some of the new features of Python 3.11.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;more-informative-error-tracebacks&quot;&gt;More Informative Error Tracebacks&lt;a class=&quot;headerlink&quot; href=&quot;#more-informative-error-tracebacks&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python is often recognized as a good beginner programming language, with its &lt;a href=&quot;https://realpython.com/python-pep8/&quot;&gt;readable&lt;/a&gt; syntax and powerful &lt;a href=&quot;https://realpython.com/python-data-structures/&quot;&gt;data structures&lt;/a&gt;. A challenge for all, but especially those new to Python, is how to interpret the &lt;a href=&quot;https://realpython.com/python-traceback/&quot;&gt;traceback&lt;/a&gt; that’s displayed when Python encounters an error.&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;, Python’s error messages were &lt;a href=&quot;https://realpython.com/python310-new-features/#better-error-messages&quot;&gt;greatly improved&lt;/a&gt;. Similarly, one of Python 3.11’s &lt;a href=&quot;https://twitter.com/pyblogsal/status/1569366992758398977&quot;&gt;most anticipated features&lt;/a&gt; will also boost your developer experience. Decorative annotations are added to the tracebacks and can help you more quickly interpret an error message.&lt;/p&gt;
&lt;p&gt;To see a quick example of the enhanced traceback, add the following code to a file named &lt;code&gt;inverse.py&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# inverse.py&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inverse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inverse&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;p&gt;You can use &lt;code&gt;inverse()&lt;/code&gt; to calculate the &lt;a href=&quot;https://en.wikipedia.org/wiki/Multiplicative_inverse&quot;&gt;multiplicative inverse&lt;/a&gt; of a number. There’s no multiplicative inverse of &lt;code&gt;0&lt;/code&gt;, so your code raises an error when you run it:&lt;/p&gt;
&lt;div class=&quot;highlight sh&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 inverse.py
&lt;span class=&quot;go&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  File &quot;/home/realpython/inverse.py&quot;, line 6, in &amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    print(inverse(0))&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;          ^^^^^^^^^^&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;  File &quot;/home/realpython/inverse.py&quot;, line 4, in inverse&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    return 1 / number&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;go&quot;&gt;           ~~^~~~~~~~&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;ZeroDivisionError: division by zero&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note the &lt;code&gt;^&lt;/code&gt; and &lt;code&gt;~&lt;/code&gt; symbols embedded within the traceback. They’re used to guide your attention to the code that’s causing the error. As usual with tracebacks, you should start at the bottom and work your way up. In this example, a &lt;code&gt;ZeroDivisionError&lt;/code&gt; is caused by the division &lt;code&gt;1 / number&lt;/code&gt;. The actual culprit is calling &lt;code&gt;inverse(0)&lt;/code&gt;, as &lt;code&gt;0&lt;/code&gt; has no inverse.&lt;/p&gt;
&lt;p&gt;Getting this extra help in spotting mistakes is useful. However, the annotated tracebacks are even more powerful if your code is more complex. They may be able to convey information that you couldn’t get from the traceback by itself before.&lt;/p&gt;
&lt;p&gt;To appreciate the power of the improved tracebacks, you’ll build a small parser of information about &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_programmers&quot;&gt;a few programmers&lt;/a&gt;. Assume you have a file named &lt;code&gt;programmers.json&lt;/code&gt; with the following content:&lt;/p&gt;
&lt;div class=&quot;highlight json&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Uncle Barry&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ada&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;last&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Lovelace&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;birth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1815&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;death&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;month&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Grace&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;last&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hopper&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;birth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1906&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;month&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;death&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1992&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;month&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ole-Johan&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;last&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Dahl&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;birth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1931&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;month&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;death&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2002&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;month&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Guido&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;last&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Van Rossum&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;birth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1956&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;month&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;death&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note that the information about the programmers is quite inconsistent. While the information about &lt;a href=&quot;https://en.wikipedia.org/wiki/Grace_Hopper&quot;&gt;Grace Hopper&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Ole-Johan_Dahl&quot;&gt;Ole-Johan Dahl&lt;/a&gt; is complete, you’re missing &lt;a href=&quot;https://en.wikipedia.org/wiki/Ada_Lovelace&quot;&gt;Ada Lovelace’s&lt;/a&gt; day and month of birth as well as her year of death. Naturally, you only have birth information about &lt;a href=&quot;https://en.wikipedia.org/wiki/Guido_van_Rossum&quot;&gt;Guido van Rossum&lt;/a&gt;. To top it off, you’ve only recorded &lt;a href=&quot;https://peps.python.org/pep-0401/&quot;&gt;Uncle Barry’s&lt;/a&gt; first name.&lt;/p&gt;
&lt;p&gt;You’ll create a class that can wrap this information. Start by reading the information from the JSON file:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# programmers.py&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;json&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pathlib&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;programmers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loads&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pathlib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;programmers.json&quot;&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;read_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;utf-8&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You use &lt;a href=&quot;https://realpython.com/python-pathlib/&quot;&gt;&lt;code&gt;pathlib&lt;/code&gt;&lt;/a&gt; to read the JSON file and &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;&lt;code&gt;json&lt;/code&gt;&lt;/a&gt; to parse the information into a Python list of dictionaries.&lt;/p&gt;
&lt;p&gt;Next, you’ll use a &lt;a href=&quot;https://realpython.com/python-data-classes/&quot;&gt;data class&lt;/a&gt; to encapsulate the information about each programmer:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# programmers.py&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;dataclasses&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataclass&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# ...&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@dataclass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Person&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;nb&quot;&gt;str&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;life_span&lt;/span&gt;&lt;span class=&quot;p&quot;&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;int&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 class=&quot;nd&quot;&gt;@classmethod&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;from_dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;info&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;cls&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;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;name&#x27;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;first&#x27;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;name&#x27;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;last&#x27;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;life_span&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;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;birth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;death&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;year&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each &lt;code&gt;Person&lt;/code&gt; will have a &lt;code&gt;name&lt;/code&gt; and a &lt;code&gt;life_span&lt;/code&gt; attribute. Additionally, you add a convenience &lt;a href=&quot;https://realpython.com/python-multiple-constructors/&quot;&gt;constructor&lt;/a&gt; that can initialize &lt;code&gt;Person&lt;/code&gt; based on the information and structure in your JSON file.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python311-new-features/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python311-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 #130: Fostering an Internal Python Community &amp; Managing the 3.11 Release</title>
      <id>https://realpython.com/podcasts/rpp/130/</id>
      <link href="https://realpython.com/podcasts/rpp/130/"/>
      <updated>2022-10-21T12:00:00+00:00</updated>
      <summary>Does your company have a plan for growing an internal Python community? What are the attributes to look for when bringing someone into your department? This week on the show, Pablo Galindo Salgado returns to talk about building community through the Python Guild at Bloomberg and managing the release of Python 3.11.</summary>
      <content type="html">
        &lt;p&gt;Does your company have a plan for growing an internal Python community? What are the attributes to look for when bringing someone into your department? This week on the show, Pablo Galindo Salgado returns to talk about building community through the Python Guild at Bloomberg and managing the release of Python 3.11.&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 Tic-Tac-Toe Game Engine With an AI Player in Python</title>
      <id>https://realpython.com/tic-tac-toe-ai-python/</id>
      <link href="https://realpython.com/tic-tac-toe-ai-python/"/>
      <updated>2022-10-19T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll build a universal game engine in Python with tic-tac-toe rules and two computer players, including an unbeatable AI player using the minimax algorithm. You&#x27;ll also create a text-based graphical front end for your library and explore two alternative front ends.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you’re a child, you learn to play &lt;a href=&quot;https://en.wikipedia.org/wiki/Tic-tac-toe&quot;&gt;tic-tac-toe&lt;/a&gt;, which some people know as naughts and crosses. The game remains fun and challenging until you enter your teenage years. Then, you learn to program and discover the joy of coding a virtual version of this two-player game. As an adult, you may still appreciate the simplicity of the game by using Python to create an opponent with &lt;strong&gt;artificial intelligence (AI)&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;By completing this detailed step-by-step adventure, you’ll build an extensible &lt;strong&gt;game engine&lt;/strong&gt; with an &lt;strong&gt;unbeatable computer player&lt;/strong&gt; that uses the &lt;strong&gt;minimax algorithm&lt;/strong&gt; to play tic-tac-toe. Along the way, you’ll dive into immutable class design, generic plug-in architecture, and modern Python code practices and patterns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a reusable &lt;strong&gt;Python library&lt;/strong&gt; with the tic-tac-toe game engine&lt;/li&gt;
&lt;li&gt;Model the &lt;strong&gt;domain&lt;/strong&gt; of tic-tac-toe following Pythonic code style&lt;/li&gt;
&lt;li&gt;Implement artificial players including one based on the &lt;strong&gt;minimax algorithm&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build a text-based &lt;strong&gt;console front end&lt;/strong&gt; for the game with a human player&lt;/li&gt;
&lt;li&gt;Explore strategies for &lt;strong&gt;performance optimizations&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click the link below to download the complete source code for this project:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/tic-tac-toe-ai-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-tic-tac-toe-ai-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to build a tic-tac-toe game engine and AI player with Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;demo-tic-tac-toe-ai-player-in-python&quot;&gt;Demo: Tic-Tac-Toe AI Player in Python&lt;a class=&quot;headerlink&quot; href=&quot;#demo-tic-tac-toe-ai-player-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;By the end of this tutorial, you’ll have a highly reusable and extensible &lt;strong&gt;Python library&lt;/strong&gt; with an abstract &lt;a href=&quot;https://realpython.com/top-python-game-engines/&quot;&gt;game engine&lt;/a&gt; for tic-tac-toe. It’ll encapsulate universal game rules and computer players, including one that never loses due to bare-bones artificial intelligence support. In addition, you’ll create a sample &lt;strong&gt;console front end&lt;/strong&gt; that builds on top of your library and implements a text-based interactive tic-tac-toe game running in the terminal.&lt;/p&gt;
&lt;p&gt;Here’s what actual gameplay between two players might look like:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/747651381?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;
  &lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Console Front End&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Generally, you may mix and choose the players from among a human player, a dummy computer player making moves at random, and a smart computer player sticking to the optimal strategy. You can also specify which player should make the first move, increasing their chances of winning or tying.&lt;/p&gt;
&lt;p&gt;Later, you’ll be able to adapt your generic tic-tac-toe library for different platforms, such as a &lt;strong&gt;windowed desktop environment&lt;/strong&gt; or a &lt;strong&gt;web browser&lt;/strong&gt;. While you’ll only follow instructions on building a console application in this tutorial, you can find &lt;a href=&quot;https://realpython.com/python-gui-tkinter/&quot;&gt;Tkinter&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/pyscript-python-in-browser/&quot;&gt;PyScript&lt;/a&gt; front end examples in the supporting materials.&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; These front ends aren’t covered here because implementing them requires considerable familiarity with &lt;a href=&quot;https://realpython.com/intro-to-python-threading/&quot;&gt;threading&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/async-io-python/&quot;&gt;asyncio&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/queue-in-python/&quot;&gt;queues&lt;/a&gt; in Python, which is beyond the scope of this tutorial. But feel free to study and play around with the sample code on your own.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The Tkinter front end is a streamlined version of the same game that’s described in a &lt;a href=&quot;https://realpython.com/tic-tac-toe-python/&quot;&gt;separate tutorial&lt;/a&gt;, which only serves as a demonstration of the library in a desktop environment:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/747651753?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;
  &lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Tkinter Front End&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Unlike the original, it doesn’t look as slick, nor does it allow you to restart the game easily. However, it adds the option to play against the computer or another human player if you want to.&lt;/p&gt;
&lt;p&gt;The PyScript front end lets you or your friends play the game in a web browser even when they don’t have &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;Python installed on their computer&lt;/a&gt;, which is a notable benefit:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/747651357?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;
  &lt;figcaption class=&quot;figure-caption text-center&quot;&gt;PyScript Front End&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;If you’re adventurous and know a little bit of PyScript or &lt;a href=&quot;https://realpython.com/python-vs-javascript/&quot;&gt;JavaScript&lt;/a&gt;, then you could extend this front end by adding the ability to play online with another human player through the network. To facilitate the communication, you’d need to implement a remote web server using the &lt;a href=&quot;https://en.wikipedia.org/wiki/WebSocket&quot;&gt;WebSocket&lt;/a&gt; protocol, for instance. Take a look at a working &lt;a href=&quot;https://realpython.com/python-xml-parser/#bind-xml-data-to-python-objects&quot;&gt;WebSocket client and server example&lt;/a&gt; in another tutorial to get an idea of how that might work.&lt;/p&gt;
&lt;p&gt;It’s worth noting that each of the three front ends demonstrated in this section merely implement a different &lt;strong&gt;presentation layer&lt;/strong&gt; for the same Python library, which provides the underlying game logic and players. There’s no unnecessary redundancy or code duplication across them, thanks to the clear &lt;a href=&quot;https://en.wikipedia.org/wiki/Separation_of_concerns&quot;&gt;separation of concerns&lt;/a&gt; and other programming principles that you’ll practice in this tutorial.&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The project that you’re going to build consists of two high-level components depicted in the diagram below:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/diagram.4802afdb24e3.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block w-66&quot; src=&quot;https://files.realpython.com/media/diagram.4802afdb24e3.png&quot; width=&quot;1643&quot; height=&quot;1294&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/diagram.4802afdb24e3.png&amp;amp;w=410&amp;amp;sig=9617c14b5d138aa2dd749961cf18f42dad82d74a 410w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/diagram.4802afdb24e3.png&amp;amp;w=821&amp;amp;sig=0afd8a1d5024a784be7869b0e142c29512e684fc 821w, https://files.realpython.com/media/diagram.4802afdb24e3.png 1643w&quot; sizes=&quot;75vw&quot; alt=&quot;Tic-Tac-Toe Architecture Diagram&quot; data-asset=&quot;4596&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Tic-Tac-Toe Architecture Diagram&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;The first component is an abstract tic-tac-toe Python library, which remains agnostic about the possible ways of presenting the game to the user in a graphical form. Instead, it contains the core logic of the game and two artificial players. However, the library can’t stand on its own, so you’re also going to create a sample front end to collect user input from the keyboard and visualize the game in the console using plain text.&lt;/p&gt;
&lt;p&gt;You’ll start by implementing the low-level details of the tic-tac-toe library, and then you’ll use those to implement a higher-level game front end in a bottom-up fashion. When you finish this tutorial, the complete file structure resulting will look like this:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/tic-tac-toe-ai-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/tic-tac-toe-ai-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Numbers and Math</title>
      <id>https://realpython.com/courses/python-basics-numbers-and-math/</id>
      <link href="https://realpython.com/courses/python-basics-numbers-and-math/"/>
      <updated>2022-10-18T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn the math that you&#x27;ll need for your Python programming journey. This includes integers and floating-point numbers, arithmetic operators, and string formatting for numbers.</summary>
      <content type="html">
        &lt;p&gt;You don&amp;rsquo;t need to be a math whiz to program well. The truth is, few
programmers need to know more than basic algebra.&lt;/p&gt;
&lt;p&gt;Of course, how much math you need to know depends on the 
application you&amp;rsquo;re working on. In general, the level of math required 
to be a programmer is lower than you might expect.&lt;/p&gt;
&lt;p&gt;Although math and computer programming aren&amp;rsquo;t as correlated as 
some people might believe, numbers are an integral part of any 
programming language, and Python is no exception.&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;Create &lt;strong&gt;integers&lt;/strong&gt; and &lt;strong&gt;floating-point&lt;/strong&gt; numbers&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;arithmetic expressions&lt;/strong&gt;, &lt;strong&gt;math functions&lt;/strong&gt;, and &lt;strong&gt;number methods&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Format and display numbers in &lt;strong&gt;strings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create &lt;strong&gt;complex numbers&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. 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>A Practical Introduction to Web Scraping in Python</title>
      <id>https://realpython.com/python-web-scraping-practical-introduction/</id>
      <link href="https://realpython.com/python-web-scraping-practical-introduction/"/>
      <updated>2022-10-17T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn all about web scraping in Python. You&#x27;ll see how to parse data from websites and interact with HTML forms using tools such as Beautiful Soup and MechanicalSoup.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;strong&gt;Web scraping&lt;/strong&gt; is the process of collecting and parsing raw data from the Web, and the Python community has come up with some pretty powerful web scraping tools.&lt;/p&gt;
&lt;p&gt;The Internet hosts perhaps the greatest source of information on the planet. Many disciplines, such as &lt;a href=&quot;https://realpython.com/learning-paths/data-science-python-core-skills/&quot;&gt;data science&lt;/a&gt;, business intelligence, and investigative reporting, can benefit enormously from collecting and analyzing data from websites. &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;Parse website data using &lt;strong&gt;string methods&lt;/strong&gt; and &lt;strong&gt;regular expressions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Parse website data using an &lt;strong&gt;HTML parser&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Interact with &lt;strong&gt;forms&lt;/strong&gt; and other website components&lt;/li&gt;
&lt;/ul&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 tutorial is adapted from the chapter “Interacting With the Web” in &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;The book uses Python’s built-in &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; editor to create and edit Python files and interact with the Python shell, so you’ll see occasional references to IDLE throughout this tutorial. However, you should have no problems running the example code from the &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;editor&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/effective-python-environment/&quot;&gt;environment&lt;/a&gt; of your choice.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-web-scraping-practical-introduction-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-web-scraping-practical-introduction-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to collect and parse data from the Web.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;scrape-and-parse-text-from-websites&quot;&gt;Scrape and Parse Text From Websites&lt;a class=&quot;headerlink&quot; href=&quot;#scrape-and-parse-text-from-websites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Collecting data from websites using an automated process is known as web scraping. Some websites explicitly forbid users from scraping their data with automated tools like the ones that you’ll create in this tutorial. Websites do this for two possible reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The site has a good reason to protect its data. For instance, Google Maps doesn’t let you request too many results too quickly.&lt;/li&gt;
&lt;li&gt;Making many repeated requests to a website’s server may use up bandwidth, slowing down the website for other users and potentially overloading the server such that the website stops responding entirely.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Before using your Python skills for web scraping, you should always check your target website’s acceptable use policy to see if accessing the website with automated tools is a violation of its terms of use. Legally, web scraping against the wishes of a website is very much a gray area.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Please be aware that the following techniques &lt;a href=&quot;https://en.wikipedia.org/wiki/Web_scraping#Legal_issues&quot;&gt;may be illegal&lt;/a&gt; when used on websites that prohibit web scraping.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;For this tutorial, you’ll use a page that’s hosted on Real Python’s server. The page that you’ll access has been set up for use with this tutorial. &lt;/p&gt;
&lt;p&gt;Now that you’ve read the disclaimer, you can get to the fun stuff. In the next section, you’ll start grabbing all the HTML code from a single web page.&lt;/p&gt;
&lt;h3 id=&quot;build-your-first-web-scraper&quot;&gt;Build Your First Web Scraper&lt;a class=&quot;headerlink&quot; href=&quot;#build-your-first-web-scraper&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;One useful package for web scraping that you can find in Python’s &lt;a href=&quot;https://docs.python.org/3/library/&quot;&gt;standard library&lt;/a&gt; is &lt;code&gt;urllib&lt;/code&gt;, which contains tools for working with URLs. In particular, the &lt;a href=&quot;https://realpython.com/urllib-request/&quot;&gt;&lt;code&gt;urllib.request&lt;/code&gt;&lt;/a&gt; module contains a function called &lt;code&gt;urlopen()&lt;/code&gt; that you can use to open a URL within a program.&lt;/p&gt;
&lt;p&gt;In IDLE’s interactive window, type the following to import &lt;code&gt;urlopen()&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;urllib.request&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The web page that you’ll open is at the following URL:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;http://olympus.realpython.org/profiles/aphrodite&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To open the web page, pass &lt;code&gt;url&lt;/code&gt; to &lt;code&gt;urlopen()&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;page&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;urlopen()&lt;/code&gt; returns an &lt;code&gt;HTTPResponse&lt;/code&gt; object:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;page&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;http.client.HTTPResponse object at 0x105fef820&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To extract the HTML from the page, first use the &lt;code&gt;HTTPResponse&lt;/code&gt; object’s &lt;code&gt;.read()&lt;/code&gt; method, which returns a sequence of bytes. Then use &lt;code&gt;.decode()&lt;/code&gt; to decode the bytes to a string using &lt;a href=&quot;https://realpython.com/python-encodings-guide/#unicode-vs-utf-8&quot;&gt;UTF-8&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;html_bytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&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;html&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;html_bytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-web-scraping-practical-introduction/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-web-scraping-practical-introduction/ »&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 #129: Using an Ellipsis in Python &amp; Goals for CPython 3.12</title>
      <id>https://realpython.com/podcasts/rpp/129/</id>
      <link href="https://realpython.com/podcasts/rpp/129/"/>
      <updated>2022-10-14T12:00:00+00:00</updated>
      <summary>Where should you use an ellipsis in Python? How does it behave as a placeholder in a script, project, or stub file? What are the next goals for the Faster CPython project? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Where should you use an ellipsis in Python? How does it behave as a placeholder in a script, project, or stub file? What are the next goals for the Faster CPython project? This week on the show, Christopher Trudeau is here, 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>ChatterBot: Build a Chatbot With Python</title>
      <id>https://realpython.com/build-a-chatbot-python-chatterbot/</id>
      <link href="https://realpython.com/build-a-chatbot-python-chatterbot/"/>
      <updated>2022-10-12T14:00:00+00:00</updated>
      <summary>Chatbots can help to provide real-time customer support and are a valuable asset in many industries. When you understand the basics of the ChatterBot library, you can build and train a self-learning chatbot with just a few lines of Python code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Chatbots can provide real-time customer support and are therefore a valuable asset in many industries. When you understand the basics of the &lt;strong&gt;ChatterBot&lt;/strong&gt; library, you can &lt;strong&gt;build and train&lt;/strong&gt; a &lt;strong&gt;self-learning chatbot&lt;/strong&gt; with just a few lines of Python code.&lt;/p&gt;
&lt;p&gt;You’ll get the basic chatbot up and running right away &lt;a href=&quot;#step-1-create-a-chatbot-using-python-chatterbot&quot;&gt;in step one&lt;/a&gt;, but the most interesting part is the learning phase, when you get to train your chatbot. The quality and preparation of your training data will make a big difference in your chatbot’s performance.&lt;/p&gt;
&lt;p&gt;To simulate a real-world process that you might go through to create an industry-relevant chatbot, you’ll learn how to customize the chatbot’s responses. You’ll do this by preparing &lt;strong&gt;WhatsApp chat data&lt;/strong&gt; to train the chatbot. You can apply a similar process to train your bot from different conversational data in any domain-specific topic.&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;Build a &lt;strong&gt;command-line chatbot&lt;/strong&gt; with ChatterBot&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Train&lt;/strong&gt; the chatbot to customize its responses&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Export&lt;/strong&gt; your WhatsApp chat history&lt;/li&gt;
&lt;li&gt;Perform &lt;strong&gt;data cleaning&lt;/strong&gt; on the chat export using &lt;strong&gt;regular expressions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Retrain&lt;/strong&gt; the chatbot with industry-specific data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll also learn how ChatterBot stores your training data, and you’ll find suggestions and pointers for &lt;a href=&quot;#next-steps&quot;&gt;next steps&lt;/a&gt;, so you can start collecting real user data and let the chatbot learn from it.&lt;/p&gt;
&lt;p&gt;Overall, in this tutorial, you’ll quickly run through the basics of creating a chatbot with ChatterBot and learn how Python allows you to get fun and useful results without needing to write a lot of code.&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;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-a-chatbot-python-chatterbot-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-a-chatbot-python-chatterbot-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to build a chatbot.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;demo&quot;&gt;Demo&lt;a class=&quot;headerlink&quot; href=&quot;#demo&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;At the end of this tutorial, you’ll have a command-line chatbot that can respond to your inputs with semi-meaningful replies:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 &quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/751629412&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;You’ll achieve that by preparing WhatsApp chat data and using it to train the chatbot. Beyond learning from your automated training, the chatbot will improve over time as it gets more exposure to questions and replies from user interactions.&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://chatterbot.readthedocs.io/en/stable/index.html&quot;&gt;The ChatterBot library&lt;/a&gt; combines language corpora, text processing, machine learning algorithms, and data storage and retrieval to allow you to build flexible chatbots.&lt;/p&gt;
&lt;p&gt;You can build an industry-specific chatbot by training it with relevant data. Additionally, the chatbot will remember user responses and continue building its internal &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_(abstract_data_type)&quot;&gt;graph structure&lt;/a&gt; to improve the responses that it can give.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Attention:&lt;/strong&gt; While ChatterBot is still a popular open source solution for building a chatbot in Python, it hasn’t been actively maintained for a while and has therefore accumulated a significant number of &lt;a href=&quot;https://github.com/gunthercox/ChatterBot/issues/&quot;&gt;issues&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are multiple forks of the project that implement fixes and updates to the existing codebase, but you’ll have to personally pick the fork that implements the solution you’re looking for and then &lt;a href=&quot;https://realpython.com/what-is-pip/#installing-packages-from-your-github-repositories&quot;&gt;install it directly from GitHub&lt;/a&gt;. A fork might also come with &lt;a href=&quot;https://github.com/feignbird/ChatterBot-spacy_fixed#installation&quot;&gt;additional installation instructions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To get started, however, you won’t use a fork. Instead, you’ll use a specific pinned version of the library, as &lt;a href=&quot;https://pypi.org/project/ChatterBot/&quot;&gt;distributed on PyPI&lt;/a&gt;. You’ll find more information about installing ChatterBot in &lt;a href=&quot;#step-1-create-a-chatbot-using-python-chatterbot&quot;&gt;step one&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In this tutorial, you’ll start with an untrained chatbot that’ll showcase how quickly you can create an interactive chatbot using Python’s ChatterBot. You’ll also notice how small the vocabulary of an untrained chatbot is.&lt;/p&gt;
&lt;p&gt;Next, you’ll learn how you can train such a chatbot and check on the slightly improved results. The more plentiful and high-quality your training data is, the better your chatbot’s responses will be.&lt;/p&gt;
&lt;p&gt;Therefore, you’ll either fetch the conversation history of one of your WhatsApp chats or use the provided &lt;code&gt;chat.txt&lt;/code&gt; file that you can download here:&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;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-a-chatbot-python-chatterbot-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-a-chatbot-python-chatterbot-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to build a chatbot.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;It’s rare that input data comes exactly in the form that you need it, so you’ll clean the chat export data to get it into a useful input format. This process will show you some tools you can use for data cleaning, which may help you prepare other input data to feed to your chatbot.&lt;/p&gt;
&lt;p&gt;After data cleaning, you’ll retrain your chatbot and give it another spin to experience the improved performance.&lt;/p&gt;
&lt;p&gt;When you work through this process from start to finish, you’ll get a good idea of how you can build and train a Python chatbot with the ChatterBot library so that it can provide an interactive experience with relevant replies.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you get started, make sure that you have a Python version available that works for this ChatterBot project. What version of Python you need depends on your operating system:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/build-a-chatbot-python-chatterbot/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/build-a-chatbot-python-chatterbot/ »&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>Providing Multiple Constructors in Your Python Classes</title>
      <id>https://realpython.com/courses/multiple-constructors-python/</id>
      <link href="https://realpython.com/courses/multiple-constructors-python/"/>
      <updated>2022-10-11T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to provide multiple constructors in your Python classes. To this end, you&#x27;ll learn different techniques, such as checking argument types, using default argument values, writing class methods, and implementing single-dispatch methods.</summary>
      <content type="html">
        &lt;p&gt;Sometimes you need to write a Python class that provides multiple ways to construct objects. In other words, you want a class that implements &lt;strong&gt;multiple constructors&lt;/strong&gt;. This kind of class comes in handy when you need to create instances using different types or numbers of arguments. Having the tools to provide multiple constructors will help you write flexible classes that can adapt to changing needs.&lt;/p&gt;
&lt;p&gt;Python offers several techniques and tools that you can use to construct classes, including simulating multiple constructors through optional arguments, customizing instance creation via class methods, and doing special dispatch with decorators. If you want to learn about these techniques and tools, then this video course is for you.&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 &lt;strong&gt;optional arguments&lt;/strong&gt; and &lt;strong&gt;type checking&lt;/strong&gt; to simulate multiple constructors&lt;/li&gt;
&lt;li&gt;Write multiple constructors using the built-in &lt;strong&gt;&lt;code&gt;@classmethod&lt;/code&gt;&lt;/strong&gt; decorator&lt;/li&gt;
&lt;li&gt;Overload your class constructors using the &lt;strong&gt;&lt;code&gt;@singledispatchmethod&lt;/code&gt;&lt;/strong&gt; decorator&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;rsquo;ll also get a peek under the hood at how Python internally &lt;strong&gt;constructs instances&lt;/strong&gt; of a regular class and how some &lt;strong&gt;standard-library classes&lt;/strong&gt; provide multiple constructors.&lt;/p&gt;
&lt;p&gt;To get the most out of this video course, you should have basic knowledge of &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; and understand how to define &lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/&quot;&gt;class methods&lt;/a&gt; with &lt;code&gt;@classmethod&lt;/code&gt;. You should also have experience working with &lt;a href=&quot;https://realpython.com/primer-on-python-decorators/&quot;&gt;decorators&lt;/a&gt; in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python News: What&#x27;s New From September 2022?</title>
      <id>https://realpython.com/python-news-september-2022/</id>
      <link href="https://realpython.com/python-news-september-2022/"/>
      <updated>2022-10-10T14:00:00+00:00</updated>
      <summary>September 2022 brought some exciting Python news! In this news summary, you&#x27;ll read about the latest release candidate of Python, the breaking changes that Python 3.10.7 introduced to fix a security vulnerability, the new releases of fundamental projects in the Python ecosystem, and more.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In &lt;strong&gt;September 2022&lt;/strong&gt;, the &lt;strong&gt;Python 3.11.0rc2&lt;/strong&gt; release candidate version became available for you to test and stay on top of Python’s latest features. This release is the last preview version before the final release of Python 3.11.0, which is scheduled for October 24, 2022.&lt;/p&gt;
&lt;p&gt;Python’s latest bugfix versions, including 3.10.7, have introduced breaking changes to cope with a security vulnerability that affects the &lt;code&gt;str&lt;/code&gt; to &lt;code&gt;int&lt;/code&gt; conversion and can leave you open to DDoS attacks.&lt;/p&gt;
&lt;p&gt;As usual, the Python ecosystem has celebrated the release of new versions of many fundamental packages, libraries, and frameworks.&lt;/p&gt;
&lt;p&gt;Let’s dive into the most exciting &lt;strong&gt;Python news&lt;/strong&gt; from the past month!&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-3110rc2-was-released&quot;&gt;Python 3.11.0rc2 Was Released&lt;a class=&quot;headerlink&quot; href=&quot;#python-3110rc2-was-released&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every month, Python releases several versions from its different development branches. New releases typically add new features, fix bugs, correct security vulnerabilities, and more. September 2022 brought several new releases for Python programmers to test, use, and enjoy. Most notable was Python’s last 3.11 release candidate.&lt;/p&gt;
&lt;p&gt;Python &lt;a href=&quot;https://pythoninsider.blogspot.com/2022/09/python-3110rc2-is-now-available.html&quot;&gt;3.11.0rc2&lt;/a&gt; was released on Monday, September 12, 2022. This is the last preview version before the final release of Python 3.11.0:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/twitter-3110rc2-release-candidate.51930a959afd.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block w-66&quot; src=&quot;https://files.realpython.com/media/twitter-3110rc2-release-candidate.51930a959afd.png&quot; width=&quot;1190&quot; height=&quot;526&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/twitter-3110rc2-release-candidate.51930a959afd.png&amp;amp;w=297&amp;amp;sig=80d64cd4fb845e44add182fb511cb5b5627191b1 297w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/twitter-3110rc2-release-candidate.51930a959afd.png&amp;amp;w=595&amp;amp;sig=3fcf924395e411764c49f6a7f6e76351dfde6679 595w, https://files.realpython.com/media/twitter-3110rc2-release-candidate.51930a959afd.png 1190w&quot; sizes=&quot;75vw&quot; alt=&quot;Twitter Post 3110rc2 Release Candidate&quot; data-asset=&quot;4633&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;&lt;a href=&quot;https://twitter.com/pyblogsal/status/1569324965752619009&quot; target=&quot;_blank&quot;&gt;Image source&lt;/a&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Only reviewed changes that fix bugs are allowed during the &lt;strong&gt;release candidate phase&lt;/strong&gt;. There will be very few, if any, code changes between this release candidate and the final release. As listed in the &lt;a href=&quot;https://www.python.org/downloads/release/python-3110rc2/&quot;&gt;release post&lt;/a&gt;, the new features of the 3.11 series, as compared to 3.10, include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0657/&quot;&gt;PEP 657&lt;/a&gt; – Include Fine-Grained Error Locations in Tracebacks&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0654/&quot;&gt;PEP 654&lt;/a&gt; – Exception Groups and &lt;code&gt;except*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0680/&quot;&gt;PEP 680&lt;/a&gt; – &lt;code&gt;tomllib&lt;/code&gt;: Support for Parsing TOML in the Standard Library&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0673/&quot;&gt;PEP 673&lt;/a&gt; – &lt;code&gt;Self&lt;/code&gt; Type&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0646/&quot;&gt;PEP 646&lt;/a&gt; – Variadic Generics&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0675/&quot;&gt;PEP 675&lt;/a&gt; – Arbitrary Literal String Type&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0655/&quot;&gt;PEP 655&lt;/a&gt; – Marking individual &lt;code&gt;TypedDict&lt;/code&gt; items as required or potentially-missing&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0681/&quot;&gt;PEP 681&lt;/a&gt; – Data Class Transforms&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Python 3.11 also comes with a couple of other exciting updates. &lt;a href=&quot;https://github.com/python/cpython/issues/90908&quot;&gt;gh-90908&lt;/a&gt; introduces task groups to &lt;code&gt;asyncio&lt;/code&gt;, and &lt;a href=&quot;https://github.com/python/cpython/issues/34627/&quot;&gt;gh-34627&lt;/a&gt; allows for atomic grouping (&lt;code&gt;(?&amp;gt;…)&lt;/code&gt;) and possessive quantifiers (&lt;code&gt;*+, ++, ?+, {m,n}+&lt;/code&gt;) in regular expressions.&lt;/p&gt;
&lt;p&gt;Plus, Python 3.11 is going to deliver faster performance:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;a href=&quot;https://github.com/faster-cpython&quot;&gt;Faster CPython Project&lt;/a&gt; is already yielding some exciting results. Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.22x speedup on the standard benchmark suite. See &lt;a href=&quot;https://docs.python.org/3.11/whatsnew/3.11.html#faster-cpython&quot;&gt;Faster CPython for details&lt;/a&gt;. (&lt;a href=&quot;https://discuss.python.org/t/the-cursed-release-of-python-3-11-0b4-is-now-available/17274&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To dive deeper into some of these cool new features of Python 3.11, check out the following resources depending on your specific needs and interests:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-september-2022/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-september-2022/ »&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 #128: Using a Memory Profiler in Python &amp; What It Can Teach You</title>
      <id>https://realpython.com/podcasts/rpp/128/</id>
      <link href="https://realpython.com/podcasts/rpp/128/"/>
      <updated>2022-10-07T12:00:00+00:00</updated>
      <summary>Have you used a memory profiler to gauge the performance of your Python application? Maybe you&#x27;re using it to troubleshoot memory issues when loading a large data science project. What could running a profiler show you about a codebase you&#x27;re learning? This week on the show, Pablo Galindo Salgado returns to talk about Memray, a powerful tracing memory profiler.</summary>
      <content type="html">
        &lt;p&gt;Have you used a memory profiler to gauge the performance of your Python application? Maybe you&#x27;re using it to troubleshoot memory issues when loading a large data science project. What could running a profiler show you about a codebase you&#x27;re learning? This week on the show, Pablo Galindo Salgado returns to talk about Memray, a powerful tracing memory profiler.&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>Minimax in Python: Learn How to Lose the Game of Nim</title>
      <id>https://realpython.com/python-minimax-nim/</id>
      <link href="https://realpython.com/python-minimax-nim/"/>
      <updated>2022-10-05T14:00:00+00:00</updated>
      <summary>The minimax algorithm can be used to find optimal strategies in many different games. In this tutorial, you&#x27;ll learn how to implement minimax in Python while playing the game of Nim. You&#x27;ll also learn how you can make the algorithm more efficient with alpha-beta pruning.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Games are fun! Their well-defined rules let you explore different strategies in search of a surefire way to win. The &lt;strong&gt;minimax algorithm&lt;/strong&gt; is used to choose the optimal move at any point in a game. You’ll learn how to implement a minimax player in Python that can play the game of Nim perfectly.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll focus on minimax. However, to visualize how the algorithm works, it’s nice to work with a concrete game. You’ll learn the rules of Nim, which is a game with simple rules and limited choices. Using Nim in the examples allows you to focus on the principles of minimax without getting lost in game rules.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;As you follow this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn the principles of the &lt;strong&gt;minimax algorithm&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Play several variants of the &lt;strong&gt;game of Nim&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implement&lt;/strong&gt; the minimax algorithm&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lose&lt;/strong&gt; Nim against a minimax player&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;alpha-beta pruning&lt;/strong&gt; to optimize the minimax algorithm&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can download the source code used in this tutorial, as well as a game simulator where you can play different variants of Nim against a minimax opponent, by clicking 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;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-minimax-nim-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-minimax-nim-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to lose the game of Nim against your minimax player.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;play-a-simplified-game-of-nim&quot;&gt;Play a Simplified Game of Nim&lt;a class=&quot;headerlink&quot; href=&quot;#play-a-simplified-game-of-nim&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Nim&quot;&gt;roots of Nim&lt;/a&gt; go back a long time. While variants of the game have been played throughout history, Nim got its name in 1901 when Charles L. Bouton published &lt;a href=&quot;https://www.jstor.org/stable/1967631&quot;&gt;Nim, a Game With a Complete Mathematical Theory&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nim is a game for two players, which always ends with one player winning. The game consists of several counters lying on the game table and the players taking turns removing one or more counters. In the first half of this tutorial, you’ll play a simplified version of Nim with the following rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;There are several &lt;strong&gt;counters&lt;/strong&gt; in a shared pile.&lt;/li&gt;
&lt;li&gt;Two players take &lt;strong&gt;alternating turns&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On their turn, a player removes &lt;strong&gt;one&lt;/strong&gt;, &lt;strong&gt;two&lt;/strong&gt;, or &lt;strong&gt;three&lt;/strong&gt; counters from the pile.&lt;/li&gt;
&lt;li&gt;The player that takes the &lt;strong&gt;last counter loses&lt;/strong&gt; the game.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll refer to this game as &lt;strong&gt;Simple-Nim&lt;/strong&gt;. &lt;a href=&quot;#have-fun-with-nim-variants&quot;&gt;Later&lt;/a&gt;, you’ll learn the rules of regular Nim. They’re not much more complicated, but Simple-Nim is easier to reason about.&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; Now it’s time to play! You’re going to start with the analog version, so clear a space on your desk. Play a few rounds of Simple-Nim to get a feel for the rules. Along the way, keep an eye out for any winning strategy that you come across.&lt;/p&gt;
&lt;p&gt;You can use any objects that you happen to have available as counters, or you can use a notepad to keep track of the current number of counters in play. Somewhere between ten and twenty counters is a good starting point for a game.&lt;/p&gt;
&lt;p&gt;If you don’t have an opponent nearby, you can play against yourself for now. By the end of the tutorial, you’ll have programmed an opponent that you can play against.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To demonstrate the rules, two players—Mindy and Maximillian—will play a game of Simple-Nim, starting with &lt;strong&gt;twelve&lt;/strong&gt; counters. Mindy goes first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Mindy takes two counters, leaving &lt;strong&gt;ten&lt;/strong&gt; in the pile.&lt;/li&gt;
&lt;li&gt;Maximillian takes one counter, leaving &lt;strong&gt;nine&lt;/strong&gt; in the pile.&lt;/li&gt;
&lt;li&gt;Mindy takes three counters, leaving &lt;strong&gt;six&lt;/strong&gt; in the pile.&lt;/li&gt;
&lt;li&gt;Maximillian takes two counters, leaving &lt;strong&gt;four&lt;/strong&gt; in the pile.&lt;/li&gt;
&lt;li&gt;Mindy takes three counters, leaving &lt;strong&gt;one&lt;/strong&gt; in the pile.&lt;/li&gt;
&lt;li&gt;Maximillian takes the &lt;strong&gt;last&lt;/strong&gt; counter and loses the game.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this game, Maximillian takes the last counter, so Mindy is the winner.&lt;/p&gt;
&lt;p&gt;Nim, including Simple-Nim, is an intriguing game because the rules are simple enough that the game can be completely analyzed. You’ll use Nim to explore the minimax algorithm, which is able to play the game perfectly. This means that a minimax player will always win the game if at all possible.&lt;/p&gt;
&lt;h2 id=&quot;get-to-know-the-minimax-algorithm&quot;&gt;Get to Know the Minimax Algorithm&lt;a class=&quot;headerlink&quot; href=&quot;#get-to-know-the-minimax-algorithm&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Games have been a fertile ground for inventing and testing &lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_intelligence&quot;&gt;artificial intelligence&lt;/a&gt; algorithms. Games are well suited to this kind of research because of their clearly defined rules. One of the most famous algorithms is &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimax&quot;&gt;minimax&lt;/a&gt;. The name describes how one player tries to maximize their score while the other player tries to minimize it.&lt;/p&gt;
&lt;p&gt;Minimax can be applied to many different games and more general decisions. In this tutorial, you’ll learn how to teach minimax to play Nim. However, you can use the same principles in other games, like &lt;a href=&quot;https://realpython.com/tic-tac-toe-python/&quot;&gt;tic-tac-toe&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Chess&quot;&gt;chess&lt;/a&gt;, as well.&lt;/p&gt;
&lt;h3 id=&quot;explore-game-trees&quot;&gt;Explore Game Trees&lt;a class=&quot;headerlink&quot; href=&quot;#explore-game-trees&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Recall the game that Mindy and Maximillian played in the previous section. The following table shows all the moves of the game:&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 class=&quot;text-right&quot;&gt;Mindy&lt;/th&gt;
&lt;th class=&quot;text-center&quot;&gt;Pile&lt;/th&gt;
&lt;th class=&quot;text-left&quot;&gt;Maximillian&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;🪙🪙🪙🪙🪙🪙🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;🪙&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;🪙🪙🪙🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;🪙🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;🪙🪙&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;🪙🪙🪙&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;🪙&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;&lt;/td&gt;
&lt;td class=&quot;text-left&quot;&gt;🪙&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;This representation of the game explicitly shows how many counters each player removed on their turn. However, there’s some redundant information in the table. You can represent the same game by only keeping track of the number of counters in the pile and whose turn it is:&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 class=&quot;text-right&quot;&gt;Player to move&lt;/th&gt;
&lt;th&gt;Pile&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;Mindy&lt;/td&gt;
&lt;td&gt;🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙 (12)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;Maximillian&lt;/td&gt;
&lt;td&gt;🪙🪙🪙🪙🪙🪙🪙🪙🪙🪙 (10)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;Mindy&lt;/td&gt;
&lt;td&gt;🪙🪙🪙🪙🪙🪙🪙🪙🪙 (9)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;Maximillian&lt;/td&gt;
&lt;td&gt;🪙🪙🪙🪙🪙🪙 (6)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;Mindy&lt;/td&gt;
&lt;td&gt;🪙🪙🪙🪙 (4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;text-right&quot;&gt;Maximillian&lt;/td&gt;
&lt;td&gt;🪙 (1)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;While the number of counters each player removed on their turn isn’t explicitly spelled out, you can work it out by comparing the number of counters in the pile before and after a turn.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-minimax-nim/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-minimax-nim/ »&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: Strings and String Methods</title>
      <id>https://realpython.com/courses/python-basics-strings-string-methods/</id>
      <link href="https://realpython.com/courses/python-basics-strings-string-methods/"/>
      <updated>2022-10-04T14:00:00+00:00</updated>
      <summary>In Python, collections of text are called strings. In this course, you&#x27;ll learn about this fundamental data type and the string methods that you can use to manipulate strings. Along the way, you&#x27;ll learn ways to work with strings of numbers, and how to format strings for printing.</summary>
      <content type="html">
        &lt;p&gt;Many programmers, regardless of their specialty, deal with text on a
daily basis. For example, web developers work with text input from
web forms. Data scientists process text to extract data and perform
tasks like sentiment analysis, which can help identify and classify
opinions in a body of text.&lt;/p&gt;
&lt;p&gt;Collections of text in Python are called &lt;strong&gt;strings&lt;/strong&gt;. Special functions
called &lt;strong&gt;string methods&lt;/strong&gt; are used to manipulate strings. There are
string methods for changing a string from lowercase to uppercase, 
removing whitespace from the beginning or end of a string, replacing
parts of a string with different text, and much more.&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;Manipulate strings with &lt;strong&gt;string methods&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Work with &lt;strong&gt;user input&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Deal with strings of &lt;strong&gt;numbers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Format&lt;/strong&gt; strings for printing&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 Enumerations of Constants With Python&#x27;s Enum</title>
      <id>https://realpython.com/python-enum/</id>
      <link href="https://realpython.com/python-enum/"/>
      <updated>2022-10-03T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to create and use enumerations of semantically related constants in Python. To do this, you&#x27;ll use the Enum class and other related tools and types from the enum module, which is available in the Python standard library.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Some programming languages, like Java and C++, include syntax that supports a data type known as &lt;strong&gt;enumerations&lt;/strong&gt;, or just &lt;strong&gt;enums&lt;/strong&gt;. This data type allows you to create sets of semantically related constants that you can access through the enumeration itself. Python doesn’t have a dedicated syntax for enums. However, the Python &lt;a href=&quot;https://docs.python.org/3/library/index.html&quot;&gt;standard library&lt;/a&gt; has an &lt;code&gt;enum&lt;/code&gt; module that supports enumerations through the &lt;code&gt;Enum&lt;/code&gt; class.&lt;/p&gt;
&lt;p&gt;If you come from a language with enumerations, and you’re used to working with them, or if you just want to learn how to use enumerations in Python, then this tutorial is for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;strong&gt;enumerations&lt;/strong&gt; of constants using Python’s &lt;strong&gt;&lt;code&gt;Enum&lt;/code&gt;&lt;/strong&gt; class&lt;/li&gt;
&lt;li&gt;Work with enumerations and their &lt;strong&gt;members&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Customize enumeration classes with &lt;strong&gt;new functionalities&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Code &lt;strong&gt;practical examples&lt;/strong&gt; to understand why you would use enumerations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, you’ll explore other specific enumeration types that live in &lt;code&gt;enum&lt;/code&gt;, including &lt;code&gt;IntEnum&lt;/code&gt;, &lt;code&gt;IntFlag&lt;/code&gt;, and &lt;code&gt;Flag&lt;/code&gt;. They’ll help you create specialized enums.&lt;/p&gt;
&lt;p&gt;To follow along with this tutorial, you should be familiar with &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt; in Python.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-enum-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-enum-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to build enumerations in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-to-know-enumerations-in-python&quot;&gt;Getting to Know Enumerations in Python&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-enumerations-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Several programming languages, including &lt;a href=&quot;https://realpython.com/java-vs-python/&quot;&gt;Java&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-vs-cpp/&quot;&gt;C++&lt;/a&gt;, have a native &lt;strong&gt;enumeration&lt;/strong&gt; or &lt;strong&gt;enum&lt;/strong&gt; data type as part of their syntax. This data type allows you to create sets of &lt;a href=&quot;https://realpython.com/python-constants/&quot;&gt;named constants&lt;/a&gt;, which are considered &lt;strong&gt;members&lt;/strong&gt; of the containing enum. You can access the members through the enumeration itself.&lt;/p&gt;
&lt;p&gt;Enumerations come in handy when you need to define an &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-immutable&quot;&gt;immutable&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Continuous_or_discrete_variable#Discrete_variable&quot;&gt;discrete&lt;/a&gt; set of similar or related constant values that may or may not have semantic meaning in your code.&lt;/p&gt;
&lt;p&gt;Days of the week, months and seasons of the year, Earth’s cardinal directions, a program’s status codes, HTTP status codes, colors in a traffic light, and pricing plans of a web service are all great examples of enumerations in programming. In general, you can use an enum whenever you have a variable that can take one of a &lt;em&gt;limited set of possible values&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Python doesn’t have an enum data type as part of its syntax. Fortunately, Python 3.4 added the &lt;a href=&quot;https://docs.python.org/3/whatsnew/3.4.html#whatsnew-enum&quot;&gt;&lt;code&gt;enum&lt;/code&gt;&lt;/a&gt; module to the &lt;a href=&quot;https://docs.python.org/3/library/index.html&quot;&gt;standard library&lt;/a&gt;. This module provides the &lt;a href=&quot;https://docs.python.org/3/library/enum.html#enum.Enum&quot;&gt;&lt;code&gt;Enum&lt;/code&gt;&lt;/a&gt; class for supporting general-purpose enumerations in Python.&lt;/p&gt;
&lt;p&gt;Enumerations were introduced by PEP 435, which defines them as follows:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;An enumeration is a set of symbolic names bound to unique, constant values. Within an enumeration, the values can be compared by identity, and the enumeration itself can be iterated over. (&lt;a href=&quot;https://peps.python.org/pep-0435/&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Before this addition to the standard library, you could create something similar to an enumeration by defining a sequence of similar or related constants. To this end, Python developers often used the following idiom:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GREEN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;YELLOW&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&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;RED&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GREEN&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Even though this idiom works, it doesn’t scale well when you’re trying to group a large number of related constants. Another inconvenience is that the first constant will have a value of &lt;code&gt;0&lt;/code&gt;, which is falsy in Python. This can be an issue in certain situations, especially those involving &lt;a href=&quot;https://realpython.com/python-boolean/&quot;&gt;Boolean&lt;/a&gt; tests.&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; If you’re using a Python version before 3.4, then you can create enumerations by installing the &lt;a href=&quot;https://pypi.org/project/enum34/&quot;&gt;enum34&lt;/a&gt; library, which is a backport of the standard-library &lt;code&gt;enum&lt;/code&gt;. The &lt;a href=&quot;https://pypi.org/project/aenum/&quot;&gt;aenum&lt;/a&gt; third-party library could be an option for you as well.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In most cases, enumerations can help you avoid the drawbacks of the above idiom. They’ll also help you produce more organized, readable, and robust code. Enumerations have several benefits, some of which relate to ease of coding:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Allowing for conveniently &lt;strong&gt;grouping related constants&lt;/strong&gt; in a sort of &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;namespace&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Allowing for &lt;strong&gt;additional behavior&lt;/strong&gt; with custom methods that operate on either enum members or the enum itself&lt;/li&gt;
&lt;li&gt;Providing quick and flexible &lt;strong&gt;access&lt;/strong&gt; to enum members&lt;/li&gt;
&lt;li&gt;Enabling &lt;strong&gt;direct iteration&lt;/strong&gt; over members, including their names and values&lt;/li&gt;
&lt;li&gt;Facilitating &lt;strong&gt;code completion&lt;/strong&gt; within &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;IDEs and editors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Enabling &lt;strong&gt;type&lt;/strong&gt; and &lt;strong&gt;error checking&lt;/strong&gt; with static checkers&lt;/li&gt;
&lt;li&gt;Providing a hub of &lt;strong&gt;searchable&lt;/strong&gt; names&lt;/li&gt;
&lt;li&gt;Mitigating &lt;strong&gt;spelling mistakes&lt;/strong&gt; when using the members of an enumeration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;They also make your code robust by providing the following benefits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ensuring &lt;strong&gt;constant values&lt;/strong&gt; that can’t be changed during the code’s execution&lt;/li&gt;
&lt;li&gt;Guaranteeing &lt;strong&gt;type safety&lt;/strong&gt; by differentiating the same value shared across several enums&lt;/li&gt;
&lt;li&gt;Improving &lt;strong&gt;readability&lt;/strong&gt; and &lt;strong&gt;maintainability&lt;/strong&gt; by using descriptive names instead of mysterious values or &lt;a href=&quot;https://en.wikipedia.org/wiki/Magic_number_(programming)&quot;&gt;magic numbers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Facilitating &lt;strong&gt;debugging&lt;/strong&gt; by taking advantage of readable names instead of values with no explicit meaning&lt;/li&gt;
&lt;li&gt;Providing a &lt;strong&gt;single source of truth&lt;/strong&gt; and &lt;strong&gt;consistency&lt;/strong&gt; throughout the code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that you know the basics of enumerations in programming and in Python, you can start creating your own enum types by using Python’s &lt;code&gt;Enum&lt;/code&gt; class.&lt;/p&gt;
&lt;h2 id=&quot;creating-enumerations-with-pythons-enum&quot;&gt;Creating Enumerations With Python’s &lt;code&gt;Enum&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#creating-enumerations-with-pythons-enum&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s &lt;code&gt;enum&lt;/code&gt; module provides the &lt;code&gt;Enum&lt;/code&gt; class, which allows you to create enumeration types. To create your own enumerations, you can either subclass &lt;code&gt;Enum&lt;/code&gt; or use its functional API. Both options will let you define a set of related constants as enum members.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-enum/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-enum/ »&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 #127: Explaining Access Control Using Python &amp; Cautiously Handling Pickles</title>
      <id>https://realpython.com/podcasts/rpp/127/</id>
      <link href="https://realpython.com/podcasts/rpp/127/"/>
      <updated>2022-09-30T12:00:00+00:00</updated>
      <summary>Have you ever used code to help explain a topic? How can Python scripts be used to understand the intricacies of access control? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Have you ever used code to help explain a topic? How can Python scripts be used to understand the intricacies of access control? This week on the show, Christopher Trudeau is here, 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>Custom Python Strings: Inheriting From str vs UserString</title>
      <id>https://realpython.com/inherit-python-str/</id>
      <link href="https://realpython.com/inherit-python-str/"/>
      <updated>2022-09-28T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to create custom string-like classes in Python by inheriting from the built-in str class or by subclassing UserString from the collections module.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The Python &lt;strong&gt;&lt;code&gt;str&lt;/code&gt;&lt;/strong&gt; class has many useful features that can help you out when you’re processing &lt;strong&gt;text&lt;/strong&gt; or &lt;strong&gt;strings&lt;/strong&gt; in your code. However, in some situations, all these great features may not be enough for you. You may need to create &lt;strong&gt;custom string-like classes&lt;/strong&gt;. To do this in Python, you can inherit from the built-in &lt;code&gt;str&lt;/code&gt; class directly or subclass &lt;code&gt;UserString&lt;/code&gt;, which lives in the &lt;code&gt;collections&lt;/code&gt; module.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create custom string-like classes by inheriting from the &lt;strong&gt;built-in &lt;code&gt;str&lt;/code&gt; class&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build custom string-like classes by subclassing &lt;strong&gt;&lt;code&gt;UserString&lt;/code&gt;&lt;/strong&gt; from the &lt;strong&gt;&lt;code&gt;collections&lt;/code&gt; module&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Decide when to use &lt;code&gt;str&lt;/code&gt; or &lt;code&gt;UserString&lt;/code&gt; to create &lt;strong&gt;custom string-like classes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Meanwhile, you’ll write a few examples that’ll help you decide whether to use &lt;code&gt;str&lt;/code&gt; or &lt;code&gt;UserString&lt;/code&gt; when you’re creating your custom string classes. Your choice will mostly depend on your specific use case.&lt;/p&gt;
&lt;p&gt;To follow along with this tutorial, it’ll help if you’re familiar with Python’s built-in &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;&lt;code&gt;str&lt;/code&gt;&lt;/a&gt; class and its standard features. You’ll also need to know the basics of &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt; in Python.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/inherit-python-str-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-inherit-python-str-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to create custom string-like classes.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;creating-string-like-classes-in-python&quot;&gt;Creating String-Like Classes in Python&lt;a class=&quot;headerlink&quot; href=&quot;#creating-string-like-classes-in-python&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-strings/&quot;&gt;&lt;code&gt;str&lt;/code&gt;&lt;/a&gt; class allows you to create &lt;strong&gt;strings&lt;/strong&gt; in Python. Strings are sequences of characters that you’ll use in many situations, especially when working with textual data. From time to time, the standard functionalities of Python’s &lt;code&gt;str&lt;/code&gt; may be insufficient to fulfill your needs. So, you may want to create custom string-like classes that solve your specific problem.&lt;/p&gt;
&lt;p&gt;You’ll typically find at least two reasons for creating custom string-like classes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Extending&lt;/strong&gt; the regular string by adding new functionality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modifying&lt;/strong&gt; the standard string’s functionality&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can also face situations in which you need to both extend &lt;em&gt;and&lt;/em&gt; modify the standard functionality of strings at the same time.&lt;/p&gt;
&lt;p&gt;In Python, you’ll commonly use one of the following techniques to create your string-like classes. You can inherit from the Python built-in &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#str&quot;&gt;&lt;code&gt;str&lt;/code&gt;&lt;/a&gt; class directly or subclass &lt;a href=&quot;https://docs.python.org/3/library/collections.html#collections.UserString&quot;&gt;&lt;code&gt;UserString&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;https://realpython.com/python-collections-module/&quot;&gt;&lt;code&gt;collections&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;, it’s common practice to use the verbs &lt;strong&gt;inherit&lt;/strong&gt; and &lt;strong&gt;subclass&lt;/strong&gt; interchangeably.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;One relevant feature of Python strings is &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-immutable&quot;&gt;immutability&lt;/a&gt;, which means that you can’t modify them &lt;a href=&quot;https://en.wikipedia.org/wiki/In-place_algorithm&quot;&gt;in place&lt;/a&gt;. So, when selecting the appropriate technique to create your own custom string-like classes, you need to consider whether your desired features will affect immutability or not.&lt;/p&gt;
&lt;p&gt;For example, if you need to modify the current behavior of existing string methods, then you’ll probably be okay subclassing &lt;code&gt;str&lt;/code&gt;. In contrast, if you need to change how strings are created, then inheriting from &lt;code&gt;str&lt;/code&gt; will demand advanced knowledge. You’ll have to override the &lt;a href=&quot;https://realpython.com/python-class-constructor/#object-creation-with-__new__&quot;&gt;&lt;code&gt;.__new__()&lt;/code&gt;&lt;/a&gt; method. In this latter case, inheriting from &lt;code&gt;UserString&lt;/code&gt; may make your life easier because you won’t have to touch &lt;code&gt;.__new__()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In the upcoming sections, you’ll learn the pros and cons of each technique so that you can decide which is the best strategy to use for your specific problem.&lt;/p&gt;
&lt;h2 id=&quot;inheriting-from-pythons-built-in-str-class&quot;&gt;Inheriting From Python’s Built-in &lt;code&gt;str&lt;/code&gt; Class&lt;a class=&quot;headerlink&quot; href=&quot;#inheriting-from-pythons-built-in-str-class&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For a long time, it was impossible to inherit directly from Python types implemented in &lt;a href=&quot;https://realpython.com/c-for-python-programmers/&quot;&gt;C&lt;/a&gt;. Python 2.2 fixed this issue. Now you can &lt;a href=&quot;https://docs.python.org/3/whatsnew/2.2.html#peps-252-and-253-type-and-class-changes&quot;&gt;subclass built-in types&lt;/a&gt;, including &lt;code&gt;str&lt;/code&gt;. This new feature is quite convenient when you need to create custom string-like classes.&lt;/p&gt;
&lt;p&gt;By inheriting from &lt;code&gt;str&lt;/code&gt; directly, you can extend and modify the standard behavior of this built-in class. You can also tweak the &lt;a href=&quot;https://realpython.com/python-class-constructor/#pythons-class-constructors-and-the-instantiation-process&quot;&gt;instantiation process&lt;/a&gt; of your custom string-like classes to perform transformations before new instances are ready.&lt;/p&gt;
&lt;h3 id=&quot;extending-the-strings-standard-behavior&quot;&gt;Extending the String’s Standard Behavior&lt;a class=&quot;headerlink&quot; href=&quot;#extending-the-strings-standard-behavior&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;An example of requiring a custom string-like class is when you need to extend the standard Python strings with new behavior. For example, say that you need a string-like class that implements a new method to count the number of words in the underlying string.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/inherit-python-str/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/inherit-python-str/ »&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>Sneaky REST APIs With Django Ninja</title>
      <id>https://realpython.com/courses/rest-apis-with-django-ninja/</id>
      <link href="https://realpython.com/courses/rest-apis-with-django-ninja/"/>
      <updated>2022-09-27T13:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to use Django Ninja, a FastAPI-inspired tool for turning Django views in REST API endpoints. With Ninja, you can quickly build API endpoints.</summary>
      <content type="html">
        &lt;p&gt;Many web projects have moved to the single-page application model. To use this model with Django, you build a project where Django is the back end accessed through a REST API. The &lt;a href=&quot;https://django-ninja.rest-framework.com/&quot;&gt;Django Ninja&lt;/a&gt; library is a FastAPI-inspired tool kit for turning Django views into REST API endpoints with very little extra code. Along the way, you&amp;rsquo;ll be using &lt;a href=&quot;https://curl.se/&quot;&gt;&lt;code&gt;curl&lt;/code&gt;&lt;/a&gt;, a command-line tool that allows you to grab the contents of a web page. &lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;d like to quickly build API endpoints and learn the ways of the Ninja, you&amp;rsquo;re in the right place.&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;REST APIs&lt;/li&gt;
&lt;li&gt;Django Ninja&lt;/li&gt;
&lt;li&gt;URL arguments and query strings&lt;/li&gt;
&lt;li&gt;Serialization through &lt;code&gt;Schema&lt;/code&gt; and &lt;code&gt;ModelSchema&lt;/code&gt; classes&lt;/li&gt;
&lt;li&gt;CRUD operations&lt;/li&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Error management&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Add Python to PATH</title>
      <id>https://realpython.com/add-python-to-path/</id>
      <link href="https://realpython.com/add-python-to-path/"/>
      <updated>2022-09-26T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about how to add Python, or any other program, to your PATH environment variable. You&#x27;ll be covering the procedure in Windows, macOS, and Linux and find out what PATH is and why it&#x27;s important.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You may need to add Python to &lt;code&gt;PATH&lt;/code&gt; if you’ve installed Python, but typing &lt;code&gt;python&lt;/code&gt; on the command line doesn’t seem to work. You may be getting a message saying that the term &lt;code&gt;python&lt;/code&gt; isn’t recognized, or you may end up with the wrong version of Python running.&lt;/p&gt;
&lt;p&gt;A common fix for these problems is adding Python to the &lt;code&gt;PATH&lt;/code&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Environment_variable&quot;&gt;environment variable&lt;/a&gt;. In this tutorial, you’ll learn how to add Python to &lt;code&gt;PATH&lt;/code&gt;. You’ll also learn about what &lt;code&gt;PATH&lt;/code&gt; is and why &lt;code&gt;PATH&lt;/code&gt; is vital for programs like the command line to be able to find your Python installation.&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; A &lt;a href=&quot;https://en.wikipedia.org/wiki/Path_(computing)&quot;&gt;path&lt;/a&gt; is the address of a file or folder on your hard drive. The &lt;code&gt;PATH&lt;/code&gt; environment variable, also referred to as just &lt;code&gt;PATH&lt;/code&gt; or &lt;em&gt;Path&lt;/em&gt;, is a list of paths to directories that your operating system keeps and uses to find executable scripts and programs.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The steps that you’ll need to take to add something to &lt;code&gt;PATH&lt;/code&gt; will depend significantly on your operating system (OS), so be sure to skip to the relevant section if you’re only interested in this procedure for one OS.&lt;/p&gt;
&lt;p&gt;Note that you can use the following steps to add any program to &lt;code&gt;PATH&lt;/code&gt;, not just Python.&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;Supplemental Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/add-python-to-path-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-add-python-to-path-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download free supplemental code&lt;/a&gt; that’ll walk you through changing PATH across operating systems.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-add-python-to-path-on-windows&quot;&gt;How to Add Python to &lt;code&gt;PATH&lt;/code&gt; on Windows&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-add-python-to-path-on-windows&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The first step is to locate the directory in which your target Python executable lives. The path to the directory is what you’ll be adding to the &lt;code&gt;PATH&lt;/code&gt; environment variable.&lt;/p&gt;
&lt;p&gt;To find the Python executable, you’ll need to look for a file called &lt;code&gt;python.exe&lt;/code&gt;. The Python executable could be in a directory in &lt;code&gt;C:\Python\&lt;/code&gt; or in your &lt;code&gt;AppData\&lt;/code&gt; folder, for instance. If the executable were in &lt;code&gt;AppData\&lt;/code&gt;, then the path would typically look something like this:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;C:\Users\&amp;lt;USER&amp;gt;\AppData\Local\Programs\Python&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In your case, the &lt;code&gt;&amp;lt;USER&amp;gt;&lt;/code&gt; part would be replaced by your currently logged-in user name.&lt;/p&gt;
&lt;p&gt;Once you’ve found the executable, make sure it works by double-clicking it and verifying that it starts up a Python REPL in a new window.&lt;/p&gt;
&lt;p&gt;If you’re struggling to find the right executable, you can use Windows Explorer’s search feature. The issue with the built-in search is that it’s painfully slow. To perform a super-fast full system search for any file, a great alternative is &lt;a href=&quot;https://www.voidtools.com/&quot;&gt;Everything&lt;/a&gt;:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/which_python_exe.b88dfad1cfb4.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/which_python_exe.b88dfad1cfb4.png&quot; width=&quot;1273&quot; height=&quot;420&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/which_python_exe.b88dfad1cfb4.png&amp;amp;w=318&amp;amp;sig=92146b5f86dae34d90cc97e8ca1c3000b57cb9b8 318w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/which_python_exe.b88dfad1cfb4.png&amp;amp;w=636&amp;amp;sig=03b497308eeb0448413e51a1f3f104af95c108bb 636w, https://files.realpython.com/media/which_python_exe.b88dfad1cfb4.png 1273w&quot; sizes=&quot;75vw&quot; alt=&#x27;A screenshot of the Everything program searching for &quot;python.exe&quot;&#x27; data-asset=&quot;4592&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Those paths highlighted in yellow, namely those at &lt;code&gt;\WindowsApps&lt;/code&gt; and &lt;code&gt;\Python310&lt;/code&gt;, would be ideal candidates to add to &lt;code&gt;PATH&lt;/code&gt; because they look like executables at the root level of an installation. Those highlighted in red wouldn’t be suitable because some are part of a virtual environment—you can see &lt;code&gt;venv&lt;/code&gt; in the path—and some are shortcuts or internal Windows installations.&lt;/p&gt;
&lt;p&gt;You may also encounter Python executables that are installed within the folder for a different program. This is due to the fact that many applications bundle their own version of Python within them. These bundled Python installations would also be unsuitable.&lt;/p&gt;
&lt;p&gt;Once you’ve located your Python executable, open the Start menu and search for the &lt;em&gt;Edit the system environment variables&lt;/em&gt; entry, which opens up a &lt;em&gt;System Properties&lt;/em&gt; window. In the &lt;em&gt;Advanced&lt;/em&gt; tab, click on the button &lt;em&gt;Environment Variables&lt;/em&gt;. There you’ll see &lt;em&gt;User&lt;/em&gt; and &lt;em&gt;System&lt;/em&gt; variables, which you’ll be able to edit:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 &quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/729132627&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;In the section entitled &lt;em&gt;User Variables&lt;/em&gt;, double-click on the entry that says &lt;em&gt;Path&lt;/em&gt;. Another window will pop up showing a list of paths. Click the &lt;em&gt;New&lt;/em&gt; button and paste the path to your Python executable there. Once that’s inserted, select your newly added path and click the &lt;em&gt;Move Up&lt;/em&gt; button until it’s at the top.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/add-python-to-path/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/add-python-to-path/ »&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 #126: Python as an Efficiency Tool for Non-Developers</title>
      <id>https://realpython.com/podcasts/rpp/126/</id>
      <link href="https://realpython.com/podcasts/rpp/126/"/>
      <updated>2022-09-23T12:00:00+00:00</updated>
      <summary>Are you interested in using Python in an industry outside of software development? Would adding a few custom software tools increase efficiency and make your coworkers&#x27; jobs easier? This week on the show, Josh Burnett talks about using Python as a mechanical engineer.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in using Python in an industry outside of software development? Would adding a few custom software tools increase efficiency and make your coworkers&#x27; jobs easier? This week on the show, Josh Burnett talks about using Python as a mechanical engineer.&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>What Does if __name__ == &quot;__main__&quot; Do in Python?</title>
      <id>https://realpython.com/if-name-main-python/</id>
      <link href="https://realpython.com/if-name-main-python/"/>
      <updated>2022-09-21T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn all about Python&#x27;s name-main idiom. You&#x27;ll learn what it does in Python, how it works, when to use it, when to avoid it, and how to refer to it.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You’ve likely encountered Python’s &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom when reading other people’s code. No wonder—&lt;a href=&quot;https://github.com/search?q=__name__+%3D%3D+%22__main__%22&amp;amp;type=code&quot;&gt;it’s widespread&lt;/a&gt;! You might have even used &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; in your own scripts. But did you use it correctly?&lt;/p&gt;
&lt;p&gt;Maybe you’ve programmed in a &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_C-family_programming_languages&quot;&gt;C-family language&lt;/a&gt; like &lt;a href=&quot;https://realpython.com/java-vs-python/&quot;&gt;Java&lt;/a&gt; before, and you wonder whether this construct is a clumsy accessory to using a &lt;code&gt;main()&lt;/code&gt; function as an &lt;a href=&quot;https://en.wikipedia.org/wiki/Entry_point#Contemporary&quot;&gt;entry point&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Syntactically, Python’s &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom is just a normal &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional block&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python&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;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The indented block starting in line 2 contains all the code that Python will execute when the conditional statement in line 1 evaluates to &lt;code&gt;True&lt;/code&gt;. In the code example above, the specific code logic that you’d put in the conditional block is represented with a placeholder &lt;a href=&quot;https://realpython.com/python-ellipsis/&quot;&gt;ellipsis&lt;/a&gt; (&lt;code&gt;...&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;So—if there’s nothing special about the &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom, then why does it &lt;em&gt;look&lt;/em&gt; confusing, and why does it continue to spark discussion in the Python community?&lt;/p&gt;
&lt;p&gt;If the idiom still seems a little cryptic, and you’re not completely sure &lt;strong&gt;what&lt;/strong&gt; it does, &lt;strong&gt;why&lt;/strong&gt; you might want it, and &lt;strong&gt;when&lt;/strong&gt; to use it, then you’ve come to the right place! In this tutorial, you’ll learn all about Python’s &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom—starting with what it really does in Python, and ending with a suggestion for a quicker way to refer to it.&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;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/if-name-main-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-if-name-main-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to understand the name-main idiom.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;in-short-it-allows-you-to-execute-code-when-the-file-runs-as-a-script-but-not-when-its-imported-as-a-module&quot;&gt;In Short: It Allows You to Execute Code When the File Runs as a Script, but Not When It’s Imported as a Module&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-it-allows-you-to-execute-code-when-the-file-runs-as-a-script-but-not-when-its-imported-as-a-module&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For most practical purposes, you can think of the conditional block that you open with &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; as a way to store code that should only run when your file is executed as a script.&lt;/p&gt;
&lt;p&gt;You’ll see what that means in a moment. For now, say you have the following file:&lt;/p&gt;
&lt;div class=&quot;highlight python&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;# echo.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;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&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;n&quot;&gt;repetitions&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;o&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;o&quot;&gt;-&amp;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;linenos&quot;&gt; 4&lt;/span&gt;    &lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Imitate a real-world echo.&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;echoed_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;repetitions&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;o&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;linenos&quot;&gt; 7&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;echoed_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&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;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;echoed_text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.&quot;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;11&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Yell something at a mountain: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;12&lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you define a function, &lt;code&gt;echo()&lt;/code&gt;, that mimics a real-world echo by gradually printing fewer and fewer of the final letters of the input text.&lt;/p&gt;
&lt;p&gt;Below that, in lines 10 to 12, you use the &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom. This code starts with the conditional statement &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; in line 10. In the indented lines, 11 and 12, you then collect user input and call &lt;code&gt;echo()&lt;/code&gt; with that input. These two lines will execute when you run &lt;code&gt;echo.py&lt;/code&gt; as a script from your command line:&lt;/p&gt;
&lt;div class=&quot;highlight sh&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 echo.py
&lt;span class=&quot;go&quot;&gt;Yell something at a mountain: HELLOOOO ECHOOOOOOOOOO&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;ooo&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;oo&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;o&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When you run the file as a script by passing the file object to your Python interpreter, the expression &lt;code&gt;__name__ == &quot;__main__&quot;&lt;/code&gt; returns &lt;code&gt;True&lt;/code&gt;. The code block under &lt;code&gt;if&lt;/code&gt; then runs, so Python collects user input and calls &lt;code&gt;echo()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Try it out yourself! You can download all the code files that you’ll use in this tutorial from 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;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/if-name-main-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-if-name-main-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to understand the name-main idiom.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;At the same time, if you import &lt;code&gt;echo()&lt;/code&gt; in another module or a console session, then the nested code won’t run:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;echo&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;echo&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;n&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Please help me I&#x27;m stuck on a mountain&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;ain&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;in&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;n&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this case, you want to use &lt;code&gt;echo()&lt;/code&gt; in the context of another script or interpreter session, so you won’t need to collect user input. Running &lt;code&gt;input()&lt;/code&gt; would mess with your code by producing a side effect when importing &lt;code&gt;echo&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;When you nest the code that’s specific to the script usage of your file under the &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom, then you avoid running code that’s irrelevant for imported modules.&lt;/p&gt;
&lt;p&gt;Nesting code under &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; allows you to cater to different use cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Script:&lt;/strong&gt; When run as a script, your code prompts the user for input, calls &lt;code&gt;echo()&lt;/code&gt;, and prints the result.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Module:&lt;/strong&gt; When you import &lt;code&gt;echo&lt;/code&gt; as a module, then &lt;code&gt;echo()&lt;/code&gt; gets defined, but no code executes. You provide &lt;code&gt;echo()&lt;/code&gt; to the main code session without any side effects.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By implementing the &lt;code&gt;if __name__ == &quot;__main__&quot;&lt;/code&gt; idiom in your code, you set up an additional entry point that allows you to use &lt;code&gt;echo()&lt;/code&gt; right from the command line.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/if-name-main-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/if-name-main-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Building Python Project Documentation With MkDocs</title>
      <id>https://realpython.com/courses/building-project-documentation-mkdocs/</id>
      <link href="https://realpython.com/courses/building-project-documentation-mkdocs/"/>
      <updated>2022-09-20T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to build professional documentation for a Python package using MkDocs and mkdocstrings. These tools allow you to generate nice-looking and modern documentation from Markdown files and, more importantly, from your code&#x27;s docstrings.</summary>
      <content type="html">
        &lt;p&gt;In this course, you&amp;rsquo;ll learn how to quickly build &lt;strong&gt;documentation&lt;/strong&gt; for a Python package using &lt;strong&gt;MkDocs&lt;/strong&gt; and &lt;strong&gt;mkdocstrings&lt;/strong&gt;. These tools allow you to generate nice-looking and modern documentation from &lt;strong&gt;Markdown&lt;/strong&gt; files and your code&amp;rsquo;s &lt;strong&gt;docstrings&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Maintaining &lt;strong&gt;auto-generated documentation&lt;/strong&gt; means less effort because you&amp;rsquo;re linking information between your code and the documentation pages. However, good documentation is &lt;em&gt;more&lt;/em&gt; than just the technical description pulled from your code! Your project will appeal more to users if you guide them through examples and connect the dots between the docstrings.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Material for MkDocs theme&lt;/strong&gt; makes your documentation &lt;strong&gt;look good&lt;/strong&gt; without any extra effort and is used by popular projects such as &lt;a href=&quot;https://typer.tiangolo.com&quot;&gt;Typer CLI&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/fastapi-python-web-apis/&quot;&gt;FastAPI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Work with &lt;strong&gt;MkDocs&lt;/strong&gt; to produce &lt;strong&gt;static pages from Markdown&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Pull in &lt;strong&gt;code documentation from docstrings&lt;/strong&gt; using &lt;strong&gt;mkdocstrings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Follow &lt;strong&gt;best practices&lt;/strong&gt; for project documentation&lt;/li&gt;
&lt;li&gt;Use the &lt;strong&gt;Material for MkDocs theme&lt;/strong&gt; to make your documentation look good&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Host&lt;/strong&gt; your documentation on &lt;strong&gt;GitHub Pages&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #125: Improve Matplotlib With Style Sheets &amp; Python Async for the Web</title>
      <id>https://realpython.com/podcasts/rpp/125/</id>
      <link href="https://realpython.com/podcasts/rpp/125/"/>
      <updated>2022-09-16T12:00:00+00:00</updated>
      <summary>Have you thought the standard output from Matplotlib is a bit generic looking? Would you like a quick way to add style and consistency to your data visualizations? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Have you thought the standard output from Matplotlib is a bit generic looking? Would you like a quick way to add style and consistency to your data visualizations? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Conditional Logic and Control Flow</title>
      <id>https://realpython.com/courses/basics-conditional-logic-control-flow/</id>
      <link href="https://realpython.com/courses/basics-conditional-logic-control-flow/"/>
      <updated>2022-09-13T14:00:00+00:00</updated>
      <summary>In this Python Basics video course, you&#x27;ll learn how 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;Much of the Python code you&amp;rsquo;ll write is unconditional. That is, the code does not 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 learn 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 Python Basics video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Compare the values of two or more variables&lt;/li&gt;
&lt;li&gt;Write &lt;code&gt;if&lt;/code&gt; statements to control the flow of your programs &lt;/li&gt;
&lt;li&gt;Handle errors with &lt;code&gt;try&lt;/code&gt; and &lt;code&gt;except&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Apply conditional logic to create simulations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. You can also check out the other &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics courses&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #124: Exploring Recursion in Python With Al Sweigart</title>
      <id>https://realpython.com/podcasts/rpp/124/</id>
      <link href="https://realpython.com/podcasts/rpp/124/"/>
      <updated>2022-09-09T12:00:00+00:00</updated>
      <summary>Have you wanted to understand recursion and how to use it in Python? Are you familiar with the call stack and how it relates to tracebacks? This week on the show, Al Sweigart talks about his new book, &quot;The Recursive Book of Recursion.&quot;</summary>
      <content type="html">
        &lt;p&gt;Have you wanted to understand recursion and how to use it in Python? Are you familiar with the call stack and how it relates to tracebacks? This week on the show, Al Sweigart talks about his new book, &quot;The Recursive Book of Recursion.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Building Command Line Interfaces With argparse</title>
      <id>https://realpython.com/courses/python-argparse-command-line-interfaces/</id>
      <link href="https://realpython.com/courses/python-argparse-command-line-interfaces/"/>
      <updated>2022-09-06T14:00:00+00:00</updated>
      <summary>In this step-by-step Python video course, you&#x27;ll learn how to take your command line Python scripts to the next level by adding a convenient command line interface that you can write with argparse.</summary>
      <content type="html">
        &lt;p&gt;One of the strengths of Python is that it comes with batteries included: it has a rich and versatile standard library that makes it one of the best programming languages for writing scripts for the &lt;a href=&quot;https://realpython.com/comparing-python-command-line-parsing-libraries-argparse-docopt-click/&quot;&gt;command line&lt;/a&gt;.
But, if you write &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;scripts&lt;/a&gt; for the command line, then you also need to provide a good command line interface, which you can create with the Python &lt;code&gt;argparse&lt;/code&gt; library.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What the Python &lt;code&gt;argparse&lt;/code&gt; library is, and why it&amp;rsquo;s important to use it if you need to write command line scripts in Python&lt;/li&gt;
&lt;li&gt;How to use the Python &lt;code&gt;argparse&lt;/code&gt; library to quickly create a simple CLI in Python&lt;/li&gt;
&lt;li&gt;What the advanced usage of the Python &lt;code&gt;argparse&lt;/code&gt; library is&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is for early &lt;a href=&quot;https://realpython.com/intermediate-python-project-ideas/&quot;&gt;intermediate&lt;/a&gt; Pythonistas who probably write scripts in Python for their everyday work but have never implemented a command line interface for their scripts. &lt;/p&gt;
&lt;p&gt;If that sounds like you, and you&amp;rsquo;re used to setting &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variable&lt;/a&gt; values at the beginning of your scripts or manually parsing the &lt;code&gt;sys.argv&lt;/code&gt; system list instead of using a more robust CLI development tool, then this video course is for you.&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 #123: Creating a Python Code Completer &amp; More Abstract Syntax Tree Projects</title>
      <id>https://realpython.com/podcasts/rpp/123/</id>
      <link href="https://realpython.com/podcasts/rpp/123/"/>
      <updated>2022-09-02T12:00:00+00:00</updated>
      <summary>How does a code completion tool work? What is an Abstract Syntax Tree, and how is it created in Python? How does an AST help you write programs and projects that inspect and modify your Python code? This week on the show, Meredydd Luff, co-founder of Anvil, shares his PyCon talk, &quot;Building a Python Code Completer.&quot;</summary>
      <content type="html">
        &lt;p&gt;How does a code completion tool work? What is an Abstract Syntax Tree, and how is it created in Python? How does an AST help you write programs and projects that inspect and modify your Python code? This week on the show, Meredydd Luff, co-founder of Anvil, shares his PyCon talk, &quot;Building a Python Code Completer.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Functions and Loops</title>
      <id>https://realpython.com/courses/python-basics-functions-loops/</id>
      <link href="https://realpython.com/courses/python-basics-functions-loops/"/>
      <updated>2022-08-30T14:00:00+00:00</updated>
      <summary>In this Python Basics video course, you&#x27;ll learn how to create user-defined functions that you can execute several times throughout your code. You&#x27;ll also try your hand at repeating code with for and while loops.</summary>
      <content type="html">
        &lt;p&gt;Functions are the building blocks of almost every Python program.
They&amp;rsquo;re where the real action takes place!&lt;/p&gt;
&lt;p&gt;In your Python Basics journey, you&amp;rsquo;ve probably encountered functions such as &lt;code&gt;print()&lt;/code&gt;, &lt;code&gt;len()&lt;/code&gt;, and &lt;code&gt;round()&lt;/code&gt;. These are all &lt;strong&gt;built-in functions&lt;/strong&gt; because they come built into the Python language itself. You can also create &lt;strong&gt;user-defined functions&lt;/strong&gt; that perform specific tasks.&lt;/p&gt;
&lt;p&gt;Functions break code into smaller chunks and are great for defining
actions that a program will execute several times throughout your
code. Instead of writing the same code each time the program needs
to perform the same task, just call the function!&lt;/p&gt;
&lt;p&gt;But sometimes you do need to repeat some code several times in a row.
This is where &lt;strong&gt;loops&lt;/strong&gt; come in.&lt;/p&gt;
&lt;p&gt;In this Python Basics video course, you&amp;rsquo;ll learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to create &lt;strong&gt;user-defined functions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to write &lt;strong&gt;&lt;code&gt;for&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;while&lt;/code&gt; loops&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>Building a URL Shortener With FastAPI and Python</title>
      <id>https://realpython.com/courses/url-shortener-fastapi/</id>
      <link href="https://realpython.com/courses/url-shortener-fastapi/"/>
      <updated>2022-08-23T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll build an app to create and manage shortened URLs. Your Python URL shortener can receive a full target URL and return a shortened URL. You&#x27;ll also use the automatically created documentation of FastAPI to try out your API endpoints.</summary>
      <content type="html">
        &lt;p&gt;In this video course, you&amp;rsquo;ll build a URL shortener with Python and FastAPI.
URLs can be extremely long and not user-friendly.
This is where a URL shortener can come in handy.
A URL shortener reduces the number of characters in a URL, making it easier to read, remember, and share.&lt;/p&gt;
&lt;p&gt;By following this step-by-step project, you&amp;rsquo;ll build a URL shortener with Python and &lt;strong&gt;FastAPI&lt;/strong&gt;.
At the end of this course, you&amp;rsquo;ll have a fully functional &lt;strong&gt;API-driven web app&lt;/strong&gt; that creates shortened URLs that forward to target URLs.&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;Create a &lt;strong&gt;REST API&lt;/strong&gt; with FastAPI&lt;/li&gt;
&lt;li&gt;Run a development web server with &lt;strong&gt;Uvicorn&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Model an &lt;strong&gt;SQLite&lt;/strong&gt; database&lt;/li&gt;
&lt;li&gt;Investigate the auto-generated &lt;strong&gt;API documentation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Interact with the database with &lt;strong&gt;CRUD actions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Optimize your app by &lt;strong&gt;refactoring&lt;/strong&gt; your code &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This URL shortener project is for intermediate Python programmers who want to try out &lt;a href=&quot;https://fastapi.tiangolo.com&quot;&gt;FastAPI&lt;/a&gt; and learn about API design, CRUD, and interaction with a database.
To follow along, it&amp;rsquo;ll help if you&amp;rsquo;re familiar with the basics of handling &lt;a href=&quot;https://realpython.com/urllib-request/&quot;&gt;HTTP requests&lt;/a&gt;.
If you need a refresher on FastAPI, &lt;a href=&quot;https://realpython.com/fastapi-python-web-apis/&quot;&gt;Using FastAPI to Build Python Web APIs&lt;/a&gt; is a great introduction.&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 #122: Configuring a Coding Environment on Windows &amp; Using TOML With Python</title>
      <id>https://realpython.com/podcasts/rpp/122/</id>
      <link href="https://realpython.com/podcasts/rpp/122/"/>
      <updated>2022-08-19T12:00:00+00:00</updated>
      <summary>Have you attempted to set up a Python development environment on Windows before? Would it be helpful to have an easy-to-follow guide to get you started? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Have you attempted to set up a Python development environment on Windows before? Would it be helpful to have an easy-to-follow guide to get you started? This week on the show, Christopher Trudeau is here, 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>Caching in Python With lru_cache</title>
      <id>https://realpython.com/courses/caching-python-lru/</id>
      <link href="https://realpython.com/courses/caching-python-lru/"/>
      <updated>2022-08-16T14:00:00+00:00</updated>
      <summary>Caching is an essential optimization technique. In this video course, you&#x27;ll learn how to use Python&#x27;s @lru_cache decorator to cache the results of your functions using the LRU cache strategy. This is a powerful technique you can use to leverage the power of caching in your implementations.</summary>
      <content type="html">
        &lt;p&gt;There are many ways to achieve fast and responsive applications. &lt;strong&gt;Caching&lt;/strong&gt; is one approach that, when used correctly, makes things much faster while decreasing the load on computing resources. &lt;/p&gt;
&lt;p&gt;Python&amp;rsquo;s &lt;a href=&quot;https://docs.python.org/3/library/functools.html&quot;&gt;&lt;code&gt;functools&lt;/code&gt; module&lt;/a&gt; comes with the &lt;a href=&quot;https://docs.python.org/3/library/functools.html#functools.lru_cache&quot;&gt;&lt;code&gt;@lru_cache&lt;/code&gt; decorator&lt;/a&gt;, which gives you the ability to cache the result of your functions using the &lt;strong&gt;Least Recently Used (LRU) strategy&lt;/strong&gt;. This is a simple yet powerful technique that you can use to leverage the power of caching in your code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;caching strategies&lt;/strong&gt; are available and how to implement them using &lt;strong&gt;Python decorators&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;LRU strategy&lt;/strong&gt; is and how it works&lt;/li&gt;
&lt;li&gt;How to improve performance by caching with the &lt;strong&gt;&lt;code&gt;@lru_cache&lt;/code&gt; decorator&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to expand the functionality of the &lt;code&gt;@lru_cache&lt;/code&gt; decorator and make it &lt;strong&gt;expire&lt;/strong&gt; after a specific time&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of this video course, you&amp;rsquo;ll have a deeper understanding of how caching works and how to take advantage of it in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #121: Moving NLP Forward With Transformer Models and Attention</title>
      <id>https://realpython.com/podcasts/rpp/121/</id>
      <link href="https://realpython.com/podcasts/rpp/121/"/>
      <updated>2022-08-12T12:00:00+00:00</updated>
      <summary>What&#x27;s the big breakthrough for Natural Language Processing (NLP) that has dramatically advanced machine learning into deep learning? What makes these transformer models unique, and what defines &quot;attention?&quot; This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, continues our talk about how machine learning (ML) models understand and generate text.</summary>
      <content type="html">
        &lt;p&gt;What&#x27;s the big breakthrough for Natural Language Processing (NLP) that has dramatically advanced machine learning into deep learning? What makes these transformer models unique, and what defines &quot;attention?&quot; This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, continues our talk about how machine learning (ML) models understand and generate text.&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>
