<?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-09-23T12:00:00+00:00</updated>
  <id>https://realpython.com/</id>
  <author>
    <name>Real Python</name>
  </author>

  
    <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>When Do You Use an Ellipsis in Python?</title>
      <id>https://realpython.com/python-ellipsis/</id>
      <link href="https://realpython.com/python-ellipsis/"/>
      <updated>2022-09-19T14:00:00+00:00</updated>
      <summary>You may have seen three dots in Python scripts. Although this syntax may look odd,  using an ellipsis is valid Python code. In this tutorial, you&#x27;ll learn when Python&#x27;s Ellipsis constant can come in handy for you.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In English writing, you can use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Ellipsis&quot;&gt;ellipsis&lt;/a&gt; to indicate that you’re leaving something out.
Essentially, you use three dots (&lt;code&gt;...&lt;/code&gt;) to replace the content.
But the ellipsis doesn’t only exist in prose—you may have seen three dots in Python source code, too.&lt;/p&gt;
&lt;p&gt;The ellipsis literal (&lt;code&gt;...&lt;/code&gt;) evaluates to Python’s &lt;strong&gt;&lt;code&gt;Ellipsis&lt;/code&gt;&lt;/strong&gt;.
Because &lt;a href=&quot;https://docs.python.org/3/library/constants.html#Ellipsis&quot;&gt;&lt;code&gt;Ellipsis&lt;/code&gt;&lt;/a&gt; is a built-in &lt;a href=&quot;https://realpython.com/python-constants/&quot;&gt;constant&lt;/a&gt;,
you can use &lt;code&gt;Ellipsis&lt;/code&gt; or &lt;code&gt;...&lt;/code&gt; without &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;importing&lt;/a&gt; it:&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;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Ellipsis&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;Ellipsis&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Ellipsis&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;Ellipsis&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Although three dots may look odd as Python syntax, there are situations where using &lt;code&gt;...&lt;/code&gt; can come in handy.
&lt;strong&gt;But when should you use &lt;code&gt;Ellipsis&lt;/code&gt; in Python?&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-ellipsis-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-ellipsis-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 master the ellipsis literal.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;in-short-use-the-ellipsis-as-a-placeholder-in-python&quot;&gt;In Short: Use the Ellipsis as a Placeholder in Python&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-use-the-ellipsis-as-a-placeholder-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While you can use &lt;code&gt;...&lt;/code&gt; and &lt;code&gt;Ellipsis&lt;/code&gt; interchangeably, you’ll commonly opt for &lt;code&gt;...&lt;/code&gt; in your code.
Similar to using three dots in English to omit content, you can use the ellipsis in Python as a placeholder for unwritten code:&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;# ellipsis_example.py&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;do_nothing&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;do_nothing&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;When you run &lt;code&gt;ellipsis_example.py&lt;/code&gt; and execute &lt;code&gt;do_nothing()&lt;/code&gt;, then Python runs without complaining:&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 ellipsis_example.py
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There’s no error when you execute a function in Python that contains only &lt;code&gt;...&lt;/code&gt; in the function body.
That means you can use an ellipsis as a placeholder similar to the &lt;a href=&quot;https://realpython.com/python-pass/&quot;&gt;&lt;code&gt;pass&lt;/code&gt; keyword&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Using three dots creates minimal visual clutter.
So, it can be convenient to replace irrelevant code when you’re sharing parts of your code online.&lt;/p&gt;
&lt;p&gt;A common time when you omit code is when you work with &lt;strong&gt;stubs&lt;/strong&gt;.
You can think of stubs as stand-ins for real functions.
Stubs can come in handy when you only need a function signature but don’t want to execute the code in the function body.
For example, you’d probably want to prevent external requests when you’re developing an application.&lt;/p&gt;
&lt;p&gt;Say you have a &lt;a href=&quot;https://realpython.com/flask-blueprint/&quot;&gt;Flask project&lt;/a&gt; where you’ve created your own visitor counter in &lt;code&gt;custom_stats.count_visitor()&lt;/code&gt;.
The &lt;code&gt;count_visitor()&lt;/code&gt; function is connected to the database where you track the number of visitors.
To not count yourself when you test your application in debug mode, you can create a stub of &lt;code&gt;count_visitor()&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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# app.py&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;flask&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Flask&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;custom_stats&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_visitor&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Flask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;count_visitor&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&gt;&lt;span class=&quot;linenos&quot;&gt;11&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;@app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;route&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;14&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;count_visitor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;15&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, world!&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Because the content of &lt;code&gt;count_visitor()&lt;/code&gt; doesn’t matter in this case, it’s a good idea to use the ellipsis in the function body.
Python calls &lt;code&gt;count_visitor()&lt;/code&gt; without error or unwanted side effects when you run your Flask application in debug mode:&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;flask --app app --debug run
&lt;span class=&quot;go&quot;&gt; * Serving Flask app &#x27;app&#x27;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; * Debug mode: on&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-ellipsis/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-ellipsis/ »&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 #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>How to Replace a String in Python</title>
      <id>https://realpython.com/replace-string-python/</id>
      <link href="https://realpython.com/replace-string-python/"/>
      <updated>2022-09-14T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to remove or replace a string or substring. You&#x27;ll go from the basic string method .replace() all the way up to a multi-layer regex pattern using the sub() function from Python&#x27;s re module.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’re looking for ways to remove or replace all or part of a &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;string&lt;/a&gt; in Python, then this tutorial is for you. You’ll be taking a fictional chat room transcript and &lt;a href=&quot;https://en.wikipedia.org/wiki/Sanitization_(classified_information)&quot;&gt;sanitizing&lt;/a&gt; it using both the &lt;strong&gt;&lt;code&gt;.replace()&lt;/code&gt; method&lt;/strong&gt; and the &lt;strong&gt;&lt;code&gt;re.sub()&lt;/code&gt; function&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In Python, the &lt;code&gt;.replace()&lt;/code&gt; method and the &lt;code&gt;re.sub()&lt;/code&gt; function are often used to clean up text by removing strings or substrings or replacing them. In this tutorial, you’ll be playing the role of a developer for a company that provides technical support through a one-to-one text chat. You’re tasked with creating a script that’ll sanitize the chat, removing any &lt;a href=&quot;https://en.wikipedia.org/wiki/Personal_data&quot;&gt;personal data&lt;/a&gt; and replacing any swear words with emoji.&lt;/p&gt;
&lt;p&gt;You’re only given one very short chat transcript:&lt;/p&gt;
&lt;div class=&quot;highlight text&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;[support_tom] 2022-08-24T10:02:23+00:00 : What can I help you with?
[johndoe] 2022-08-24T10:03:15+00:00 : I CAN&#x27;T CONNECT TO MY BLASTED ACCOUNT
[support_tom] 2022-08-24T10:03:30+00:00 : Are you sure it&#x27;s not your caps lock?
[johndoe] 2022-08-24T10:04:03+00:00 : Blast! You&#x27;re right!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Even though this transcript is short, it’s typical of the type of chats that agents have all the time. It has user identifiers, &lt;a href=&quot;https://en.wikipedia.org/wiki/ISO_8601&quot;&gt;ISO time stamps&lt;/a&gt;, and messages.&lt;/p&gt;
&lt;p&gt;In this case, the client &lt;code&gt;johndoe&lt;/code&gt; filed a complaint, and company policy is to sanitize and simplify the transcript, then pass it on for independent evaluation. Sanitizing the message is your job!&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/replace-string-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-replace-string-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to replace strings in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The first thing you’ll want to do is to take care of any swear words.&lt;/p&gt;
&lt;h2 id=&quot;how-to-remove-or-replace-a-python-string-or-substring&quot;&gt;How to Remove or Replace a Python String or Substring&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-remove-or-replace-a-python-string-or-substring&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The most basic way to replace a string in Python is to use the &lt;code&gt;.replace()&lt;/code&gt; string method:&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;s2&quot;&gt;&quot;Fake Python&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Fake&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Real&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Real Python&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As you can see, you can chain &lt;code&gt;.replace()&lt;/code&gt; onto any string and provide the method with two arguments. The first is the string that you want to replace, and the second is the replacement.&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; Although the Python shell displays the result of &lt;code&gt;.replace()&lt;/code&gt;, the string itself stays unchanged. You can see this more clearly by assigning your string to a variable:&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;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Fake Python&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Fake&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Real&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Real Python&#x27;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Fake Python&#x27;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Fake&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Real&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Real Python&#x27;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Real Python&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice that when you simply call &lt;code&gt;.replace()&lt;/code&gt;, the value of &lt;code&gt;name&lt;/code&gt; doesn’t change. But when you assign the result of &lt;code&gt;name.replace()&lt;/code&gt; to the &lt;code&gt;name&lt;/code&gt; variable, &lt;code&gt;&#x27;Fake Python&#x27;&lt;/code&gt; becomes &lt;code&gt;&#x27;Real Python&#x27;&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now it’s time to apply this knowledge to the transcript:&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;transcript&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[support_tom] 2022-08-24T10:02:23+00:00 : What can I help you with?&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[johndoe] 2022-08-24T10:03:15+00:00 : I CAN&#x27;T CONNECT TO MY BLASTED ACCOUNT&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[support_tom] 2022-08-24T10:03:30+00:00 : Are you sure it&#x27;s not your caps lock?&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[johndoe] 2022-08-24T10:04:03+00:00 : Blast! You&#x27;re right!&quot;&quot;&quot;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transcript&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;BLASTED&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;😤&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[support_tom] 2022-08-24T10:02:23+00:00 : What can I help you with?&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[johndoe] 2022-08-24T10:03:15+00:00 : I CAN&#x27;T CONNECT TO MY 😤 ACCOUNT&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[support_tom] 2022-08-24T10:03:30+00:00 : Are you sure it&#x27;s not your caps lock?&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[johndoe] 2022-08-24T10:04:03+00:00 : Blast! You&#x27;re right!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Loading the transcript as a &lt;a href=&quot;https://realpython.com/python-data-types/#triple-quoted-strings&quot;&gt;triple-quoted string&lt;/a&gt; and then using the &lt;code&gt;.replace()&lt;/code&gt; method on one of the swear words works fine. But there’s another swear word that’s not getting replaced because in Python, the string needs to match &lt;em&gt;exactly&lt;/em&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;s2&quot;&gt;&quot;Fake Python&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fake&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Real&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Fake Python&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As you can see, even if the casing of one letter doesn’t match, it’ll prevent any replacements. This means that if you’re using the &lt;code&gt;.replace()&lt;/code&gt; method, you’ll need to call it various times with the variations. In this case, you can just chain on another call to &lt;code&gt;.replace()&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;transcript&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;BLASTED&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;😤&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Blast&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;😤&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[support_tom] 2022-08-24T10:02:23+00:00 : What can I help you with?&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[johndoe] 2022-08-24T10:03:15+00:00 : I CAN&#x27;T CONNECT TO MY 😤 ACCOUNT&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[support_tom] 2022-08-24T10:03:30+00:00 : Are you sure it&#x27;s not your caps lock?&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[johndoe] 2022-08-24T10:04:03+00:00 : 😤! You&#x27;re right!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Success! But you’re probably thinking that this isn’t the best way to do this for something like a general-purpose transcription sanitizer. You’ll want to move toward some way of having a list of replacements, instead of having to type out &lt;code&gt;.replace()&lt;/code&gt; each time.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/replace-string-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/replace-string-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: Conditional Logic &amp; 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>Custom Python Lists: Inheriting From list vs UserList</title>
      <id>https://realpython.com/inherit-python-list/</id>
      <link href="https://realpython.com/inherit-python-list/"/>
      <updated>2022-09-12T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to create custom list-like classes in Python by inheriting from the built-in list class or by subclassing UserList from the collections module.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;At some point in your Python coding adventure, you may need to create &lt;strong&gt;custom list-like classes&lt;/strong&gt; with modified behavior, new functionalities, or both. To do this in Python, you can inherit from an &lt;a href=&quot;https://docs.python.org/3/library/collections.abc.html#module-collections.abc&quot;&gt;abstract base class&lt;/a&gt;, subclass the built-in &lt;code&gt;list&lt;/code&gt; class directly, or inherit from &lt;code&gt;UserList&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 list-like classes by inheriting from the &lt;strong&gt;built-in &lt;code&gt;list&lt;/code&gt; class&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build custom list-like classes by subclassing &lt;strong&gt;&lt;code&gt;UserList&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;/ul&gt;
&lt;p&gt;You’ll also write some examples that’ll help you decide which parent class, &lt;code&gt;list&lt;/code&gt; or &lt;code&gt;UserList&lt;/code&gt;, to use when creating your custom list classes.&lt;/p&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with Python’s built-in &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;&lt;code&gt;list&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 understand how &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt; works 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;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/inherit-python-list-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-inherit-python-list-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the source code&lt;/a&gt; that you’ll use to create custom list-like classes.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;creating-list-like-classes-in-python&quot;&gt;Creating List-Like Classes in Python&lt;a class=&quot;headerlink&quot; href=&quot;#creating-list-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-lists-tuples/&quot;&gt;&lt;code&gt;list&lt;/code&gt;&lt;/a&gt; class is a fundamental data type in Python. Lists are useful in many situations and have tons of practical use cases. In some of these use cases, the standard functionality of Python &lt;code&gt;list&lt;/code&gt; may be insufficient, and you may need to create custom list-like classes to address the problem at hand.&lt;/p&gt;
&lt;p&gt;You’ll typically find at least two reasons for creating custom list-like classes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Extending&lt;/strong&gt; the regular list by adding new functionality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modifying&lt;/strong&gt; the standard list’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 list’s standard functionality.&lt;/p&gt;
&lt;p&gt;Depending on your specific needs and skill level, you can use a few strategies to create your own custom list-like classes. You can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Inherit from an appropriate abstract base class, such as &lt;a href=&quot;https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableSequence&quot;&gt;&lt;code&gt;MutableSequence&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Inherit from the Python built-in &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#list&quot;&gt;&lt;code&gt;list&lt;/code&gt;&lt;/a&gt; class directly&lt;/li&gt;
&lt;li&gt;Subclass &lt;a href=&quot;https://docs.python.org/3/library/collections.html#collections.UserList&quot;&gt;&lt;code&gt;UserList&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;/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; 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;There are a few considerations when you’re selecting the appropriate strategy to use. Keep reading for more details.&lt;/p&gt;
&lt;h2 id=&quot;building-a-list-like-class-from-an-abstract-base-class&quot;&gt;Building a List-Like Class From an Abstract Base Class&lt;a class=&quot;headerlink&quot; href=&quot;#building-a-list-like-class-from-an-abstract-base-class&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can create your own list-like classes by inheriting from an appropriate &lt;strong&gt;abstract base class (ABC)&lt;/strong&gt;, like &lt;a href=&quot;https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableSequence&quot;&gt;&lt;code&gt;MutableSequence&lt;/code&gt;&lt;/a&gt;. This ABC provides generic implementations of most &lt;code&gt;list&lt;/code&gt; methods except for &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__getitem__&quot;&gt;&lt;code&gt;.__getitem__()&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__setitem__&quot;&gt;&lt;code&gt;.__setitem__()&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__delitem__&quot;&gt;&lt;code&gt;.__delitem__&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__len__&quot;&gt;&lt;code&gt;.__len__()&lt;/code&gt;&lt;/a&gt;, and &lt;code&gt;.insert()&lt;/code&gt;. So, when inheriting from this class, you’ll have to implement these methods yourself.&lt;/p&gt;
&lt;p&gt;Writing your own implementation for all these &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-special-method&quot;&gt;special methods&lt;/a&gt; is a fair amount of work. It’s error-prone and requires advanced knowledge of Python and its &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html&quot;&gt;data model&lt;/a&gt;. It can also imply performance issues because you’ll be writing the methods in pure Python.&lt;/p&gt;
&lt;p&gt;Additionally, suppose you need to customize the functionality of any other standard list method, like &lt;a href=&quot;https://realpython.com/python-append/&quot;&gt;&lt;code&gt;.append()&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;.insert()&lt;/code&gt;. In that case, you’ll have to override the default implementation and provide a suitable implementation that fulfills your needs.&lt;/p&gt;
&lt;p&gt;The main advantage of this strategy for creating list-like classes is that the parent ABC class will alert you if you miss any required methods in your custom implementation.&lt;/p&gt;
&lt;p&gt;In general, you should embrace this strategy only if you need a list-like class that’s fundamentally different from the built-in &lt;code&gt;list&lt;/code&gt; class.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll focus on creating list-like classes by inheriting from the built-in &lt;code&gt;list&lt;/code&gt; class and the &lt;code&gt;UserList&lt;/code&gt; class from the standard-library &lt;code&gt;collections&lt;/code&gt; module. These strategies seem to be the quickest and most practical ones.&lt;/p&gt;
&lt;h2 id=&quot;inheriting-from-pythons-built-in-list-class&quot;&gt;Inheriting From Python’s Built-in &lt;code&gt;list&lt;/code&gt; Class&lt;a class=&quot;headerlink&quot; href=&quot;#inheriting-from-pythons-built-in-list-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;list&lt;/code&gt;. This change has brought several technical advantages to the subclasses because now they:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Will work in every place that requires the original built-in type&lt;/li&gt;
&lt;li&gt;Can define new &lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/#instance-methods&quot;&gt;instance&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/#static-methods&quot;&gt;static&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/#class-methods&quot;&gt;class&lt;/a&gt; methods&lt;/li&gt;
&lt;li&gt;Can store their &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/#class-and-instance-attributes&quot;&gt;instance attributes&lt;/a&gt; in a &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__slots__&quot;&gt;&lt;code&gt;.__slots__&lt;/code&gt;&lt;/a&gt; class attribute, which essentially replaces the &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#object.__dict__&quot;&gt;&lt;code&gt;.__dict__&lt;/code&gt;&lt;/a&gt; attribute&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/inherit-python-list/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/inherit-python-list/ »&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 #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>HTML and CSS for Python Developers</title>
      <id>https://realpython.com/html-css-python/</id>
      <link href="https://realpython.com/html-css-python/"/>
      <updated>2022-09-07T14:00:00+00:00</updated>
      <summary>There&#x27;s no way around HTML and CSS when you want to build web apps.
Even if you&#x27;re not aiming to become a web developer, knowing the basics of HTML and CSS will help you understand the web better.
In this tutorial, you&#x27;ll get an introduction to HTML and CSS for Python programmers.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you want to build websites as a Python programmer, there’s no way around HTML and CSS.
Almost every website on the Internet is built with &lt;strong&gt;HTML markup&lt;/strong&gt; to structure the page.
To make a website look nice, you can style HTML with &lt;strong&gt;CSS&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you’re interested in web development with Python, then knowing HTML and CSS will help you understand web frameworks like &lt;strong&gt;Django&lt;/strong&gt; and &lt;strong&gt;Flask&lt;/strong&gt; better.
But even if you’re just getting started with Python, HTML and CSS can enable you to create small websites to impress your friends.&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;Structure a basic &lt;strong&gt;HTML&lt;/strong&gt; file&lt;/li&gt;
&lt;li&gt;View and inspect HTML in your &lt;strong&gt;browser&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Insert &lt;strong&gt;images&lt;/strong&gt; and page &lt;strong&gt;links&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Style a website with &lt;strong&gt;CSS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Format HTML with &lt;strong&gt;accessibility&lt;/strong&gt; in mind&lt;/li&gt;
&lt;li&gt;Use Python to &lt;strong&gt;write and parse&lt;/strong&gt; HTML code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll get an introduction to HTML and CSS that you can follow along with.
Throughout this tutorial, you’ll build a website with three pages and CSS styling:&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/740468859?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;While creating the web project, you’ll craft a boilerplate HTML document that you can use in your upcoming web projects.
You may find that the source code will come in handy when you’re working on future projects.
You can download it 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;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/html-css-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-html-css-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the supplemental materials for this tutorial&lt;/a&gt;, including a time-saving HTML template file.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;After learning the basics of HTML and CSS, you’ll find ideas on how to continue your journey at the end of the tutorial.&lt;/p&gt;
&lt;h2 id=&quot;create-your-first-html-file&quot;&gt;Create Your First HTML File&lt;a class=&quot;headerlink&quot; href=&quot;#create-your-first-html-file&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Think of any website that you’ve recently visited.
Maybe you read some news, chatted with friends, or watched a video.
No matter what kind of website it was, you can bet that its source code has a basic &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; tag at the beginning.&lt;/p&gt;
&lt;p&gt;HTML stands for &lt;strong&gt;HyperText Markup Language&lt;/strong&gt;.
HTML was created by &lt;a href=&quot;https://en.wikipedia.org/wiki/Tim_Berners-Lee&quot;&gt;Tim Berners-Lee&lt;/a&gt;, whose name might also ring a bell for you as the &lt;a href=&quot;https://en.wikipedia.org/wiki/World_Wide_Web&quot;&gt;inventor of the World Wide Web&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;hypertext&lt;/strong&gt; part of HTML refers to building connections between different HTML pages.
With hyperlinks, you can jump between pages and surf the Web.&lt;/p&gt;
&lt;p&gt;You use &lt;strong&gt;markup&lt;/strong&gt; to structure content in a document. 
In contrast to formatting, the markup defines the meaning of content and not how it looks.
In this section, you’ll learn about HTML elements and their roles.&lt;/p&gt;
&lt;p&gt;Writing &lt;strong&gt;semantic&lt;/strong&gt; HTML code will make your documents &lt;strong&gt;accessible&lt;/strong&gt; for a wide range of visitors.
After all, you want to enable everybody to consume your content, whether they’re visiting your page with a browser or using &lt;a href=&quot;https://en.wikipedia.org/wiki/Screen_reader&quot;&gt;screen reading&lt;/a&gt; tools.&lt;/p&gt;
&lt;p&gt;For each HTML element, there’s a standard that defines its intended use.
Today, the standards of HTML are defined by the &lt;a href=&quot;https://whatwg.org&quot;&gt;Web Hypertext Application Technology Working Group (WHATWG)&lt;/a&gt;.
The WHATWG plays a similar role for HTML as the &lt;a href=&quot;https://github.com/python/steering-council&quot;&gt;Python Steering Council&lt;/a&gt; does for Python.&lt;/p&gt;
&lt;p&gt;Approximately &lt;a href=&quot;https://w3techs.com/technologies/details/ml-html5&quot;&gt;95 percent of websites use HTML&lt;/a&gt;, so you’ll be hard-pressed to avoid it if you want to do any web development work in Python.&lt;/p&gt;
&lt;p&gt;In this section, you’ll start by creating your first HTML file.
You’ll learn how to structure your HTML code to make it readable for your browser and for humans.&lt;/p&gt;
&lt;h3 id=&quot;the-html-document&quot;&gt;The HTML Document&lt;a class=&quot;headerlink&quot; href=&quot;#the-html-document&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In this section, you’ll create a basic HTML file.
The HTML file will contain the base structure that most websites are built with.&lt;/p&gt;
&lt;p&gt;To start things off, create a file named &lt;code&gt;index.html&lt;/code&gt; with some text:&lt;/p&gt;
&lt;div class=&quot;highlight html&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;cm&quot;&gt;&amp;lt;!-- index.html --&amp;gt;&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;Am I HTML already?
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Traditionally, the first file of your website is called &lt;code&gt;index.html&lt;/code&gt;.
You can think of the &lt;code&gt;index.html&lt;/code&gt; page as akin to the &lt;code&gt;main.py&lt;/code&gt; or &lt;code&gt;app.py&lt;/code&gt; file in a Python project.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Unless your server is configured differently, &lt;code&gt;index.html&lt;/code&gt; is the file that the server tries to load when you visit the root URL. That’s why you can visit &lt;a href=&quot;https://www.example.com/&quot;&gt;https://www.example.com/&lt;/a&gt; instead of typing the full &lt;a href=&quot;https://www.example.com/index.html&quot;&gt;https://www.example.com/index.html&lt;/a&gt; address.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;So far, the only content of &lt;code&gt;index.html&lt;/code&gt; is a plain &lt;code&gt;Am I HTML already?&lt;/code&gt; string.
You haven’t added any HTML syntax yet, except an &lt;strong&gt;HTML comment&lt;/strong&gt; on line 1.
Similar to the Python interpreter not executing comments in your Python code, the browser won’t render the contents of your &lt;a href=&quot;https://html.com/tags/comment-tag/&quot;&gt;HTML comments&lt;/a&gt;.
Still, go ahead and open &lt;code&gt;index.html&lt;/code&gt; in your browser:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/html-css-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/html-css-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 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>Python News: What&#x27;s New From August 2022</title>
      <id>https://realpython.com/python-news-august-2022/</id>
      <link href="https://realpython.com/python-news-august-2022/"/>
      <updated>2022-09-05T14:00:00+00:00</updated>
      <summary>In August 2022, Python inched closer to the 3.11 release, pandas introduced enhancement proposals, various packages saw new releases, Python extended its lead at the top of the TIOBE index, and PyPI battled malware.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In &lt;strong&gt;August 2022&lt;/strong&gt;, Python inched closer to the &lt;strong&gt;3.11 release&lt;/strong&gt;, &lt;strong&gt;pandas&lt;/strong&gt; introduced &lt;strong&gt;enhancement proposals&lt;/strong&gt;, various packages saw &lt;strong&gt;new releases&lt;/strong&gt;, Python extended its lead at the top of the &lt;strong&gt;TIOBE index&lt;/strong&gt;, and &lt;strong&gt;PyPI&lt;/strong&gt; battled &lt;strong&gt;malware&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Read on for more details about what happened in the world of Python in August 2022!&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-has-peps-numpy-has-neps-pandas-now-has-pdeps&quot;&gt;Python Has PEPs, NumPy Has NEPs, pandas Now Has PDEPs&lt;a class=&quot;headerlink&quot; href=&quot;#python-has-peps-numpy-has-neps-pandas-now-has-pdeps&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The first &lt;a href=&quot;https://pandas.pydata.org/&quot;&gt;pandas&lt;/a&gt; enhancement proposal (PDEP) was submitted on August 3, 2022, and was entitled &lt;em&gt;Purpose and guidelines&lt;/em&gt;. &lt;strong&gt;Enhancement proposals&lt;/strong&gt; aren’t new to the Python community. Python has had &lt;a href=&quot;https://peps.python.org/&quot;&gt;PEPs&lt;/a&gt; since 2000, and NumPy followed with &lt;a href=&quot;https://numpy.org/neps/&quot;&gt;NEPs&lt;/a&gt; in 2017.&lt;/p&gt;
&lt;p&gt;The first &lt;strong&gt;PDEP&lt;/strong&gt; follows in the tradition of PEPs and NEPs, with &lt;a href=&quot;https://pandas.pydata.org/pdeps/0001-purpose-and-guidelines.html&quot;&gt;PDEP-1&lt;/a&gt; being an introduction to the idea behind the enhancement proposals themselves.&lt;/p&gt;
&lt;p&gt;In a nutshell, PDEPs are intended to aid the proposal process for &lt;em&gt;major&lt;/em&gt; changes to pandas, such as moving a module from the main pandas repository to a break-off repository. PDEPs are not for quick fixes, but for major undertakings that involve the wider community and, more often than not, some significant trade-offs.&lt;/p&gt;
&lt;p&gt;Working out complex issues isn’t ideally suited to a thread-based medium, like &lt;a href=&quot;https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues&quot;&gt;GitHub issues&lt;/a&gt;. It can be hard for a discussion to stay focused if anyone can respond at any time, even if the original idea is a good one.&lt;/p&gt;
&lt;p&gt;GitHub issue threads can create noise not only for the core developers, but for contributors and end users too. Additionally, they can bury good but complex ideas by not providing an appropriate medium for discussing them. Contributor &lt;a href=&quot;https://github.com/h-vetinari&quot;&gt;h-vetinari&lt;/a&gt; raised this topic in a &lt;a href=&quot;https://github.com/pandas-dev/pandas/issues/28568&quot;&gt;GitHub issue&lt;/a&gt; in 2019:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The more intricate the API implications, the harder it is to discuss in GitHub comments (because there is usually too many things to consider at the same time, or the comments/threads get ridiculously long or both). That does not mean that the given change does not have merit though, just that it’s (likely) too hard to discuss in a thread format. (&lt;a href=&quot;https://github.com/pandas-dev/pandas/issues/28568#issuecomment-540456539&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The GitHub issue that h-vetinari raised three years ago has now been closed with the &lt;a href=&quot;https://github.com/pandas-dev/pandas/pull/47444&quot;&gt;pull request&lt;/a&gt; for PDEP-1. This may lay a blueprint for the PDEP life cycle going forward. PDEPs will probably get started when someone &lt;a href=&quot;https://github.com/pandas-dev/pandas/issues/new/choose&quot;&gt;creates an issue&lt;/a&gt;. If the issue is recognized as being significant and valuable, then the person who raised it may be directed to create a PDEP.&lt;/p&gt;
&lt;p&gt;This move to PDEPs means that the &lt;a href=&quot;https://pandas.pydata.org/about/roadmap.html&quot;&gt;roadmap&lt;/a&gt; that’s typically used for communicating larger changes to pandas will slowly migrate toward PDEPs.&lt;/p&gt;
&lt;p&gt;How do you feel about the move to PDEPs? Share your thoughts in the comments!&lt;/p&gt;
&lt;h2 id=&quot;python-ecosystem-celebrates-new-releases&quot;&gt;Python Ecosystem Celebrates New Releases&lt;a class=&quot;headerlink&quot; href=&quot;#python-ecosystem-celebrates-new-releases&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Python community didn’t rest throughout August, even though it’s typically a month for vacations. As usual, there have been plenty of releases in the Python ecosystem. From CPython to CircuitPython, there are plenty of new features for you to start playing with. Read on for a selection of releases and milestones.&lt;/p&gt;
&lt;h3 id=&quot;cpython&quot;&gt;CPython&lt;a class=&quot;headerlink&quot; href=&quot;#cpython&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The CPython team is still gearing up for the release of Python 3.11 in October 2022. If you’re interested in learning more about the 3.11 release, check out some in-depth Real Python tutorials exploring the new 3.11 features, such as &lt;a href=&quot;https://realpython.com/python311-exception-groups/&quot;&gt;exception groups&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python311-tomllib/&quot;&gt;&lt;code&gt;tomllib&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python311-error-messages/&quot;&gt;better error messages&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-august-2022/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-august-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 #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>How Can You Install a Pre-Release Version of Python?</title>
      <id>https://realpython.com/python-pre-release/</id>
      <link href="https://realpython.com/python-pre-release/"/>
      <updated>2022-08-31T14:00:00+00:00</updated>
      <summary>If you want to have a peek at what&#x27;s coming in the next stable version of Python, then you can install a pre-release version. In this tutorial, you&#x27;ll learn how to access the latest Python versions and help test them.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The Python language is in constant development.
A new version is released &lt;a href=&quot;https://peps.python.org/pep-0602/&quot;&gt;annually&lt;/a&gt; in October to &lt;a href=&quot;https://realpython.com/python-news-october-2021/#a-live-python-310-release-party-on-youtube&quot;&gt;great fanfare&lt;/a&gt;.
Before these stable releases, you can preview the new features by installing a pre-release of Python.&lt;/p&gt;
&lt;p&gt;Volunteers worldwide work on developing Python by updating the &lt;strong&gt;documentation&lt;/strong&gt;, reporting &lt;strong&gt;issues&lt;/strong&gt;, suggesting and discussing &lt;strong&gt;improvements&lt;/strong&gt;, fixing &lt;strong&gt;bugs&lt;/strong&gt;, and implementing &lt;strong&gt;new features&lt;/strong&gt;.
You can join this work and &lt;a href=&quot;https://realpython.com/start-contributing-python/&quot;&gt;contribute&lt;/a&gt; to the efforts.&lt;/p&gt;
&lt;p&gt;The best way to start getting involved in the development of Python is to install and test early versions of the next release, whether it’s in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha&quot;&gt;alpha&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta&quot;&gt;beta&lt;/a&gt;, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_release_life_cycle#Release_candidate&quot;&gt;release candidate&lt;/a&gt; phase.
&lt;a href=&quot;https://twitter.com/pyblogsal&quot;&gt;Pablo Galindo Salgado&lt;/a&gt;, the release manager for Python 3.10 and 3.11, put it succinctly:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In summary: no matter who you are or what you do.
Test the beta releases!
(&lt;a href=&quot;https://discuss.python.org/t/the-last-3-11-beta-release-3-11-0b5-is-now-available/17693&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Python is essential to many people’s workflows and companies’ infrastructures.
Therefore, the community must thoroughly test new Python versions before the stable release.
You use Python differently from anyone else and may be able to reveal a bug that no one else has discovered.
Installing a pre-release version of Python and playing with it is valuable to the ecosystem.
Plus, it’s fun!&lt;/p&gt;
&lt;p&gt;You’re excited to install an early version of Python and try out the &lt;a href=&quot;https://realpython.com/search?kind=article&amp;amp;q=new+features&quot;&gt;latest features&lt;/a&gt;.
One question remains: &lt;strong&gt;How can you install a pre-release version of Python?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn about some options for getting your hands on an early version of Python and previewing its features.&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;in-short-use-pyenv-to-manage-several-versions-of-python-including-the-latest-pre-release&quot;&gt;In Short: Use &lt;code&gt;pyenv&lt;/code&gt; to Manage Several Versions of Python, Including the Latest Pre-Release&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-use-pyenv-to-manage-several-versions-of-python-including-the-latest-pre-release&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You shouldn’t use a pre-release version of Python as the only Python on your computer.
By their nature, pre-releases may be unstable or have bugs that can interfere with your day-to-day Python work.
You should therefore install the pre-release version side by side with your regular Python.&lt;/p&gt;
&lt;p&gt;One great tool for installing and managing several versions of Python on your computer is &lt;a href=&quot;https://github.com/pyenv/pyenv&quot;&gt;&lt;code&gt;pyenv&lt;/code&gt;&lt;/a&gt;.
With &lt;code&gt;pyenv&lt;/code&gt;, you can install many Python versions on your computer and switch between them with a simple command.
You can even set up project-specific Python versions that are automatically invoked.&lt;/p&gt;
&lt;p&gt;If you’re not already using &lt;code&gt;pyenv&lt;/code&gt;, then you first need to install it.
How you install &lt;code&gt;pyenv&lt;/code&gt; depends on your operating system.
Choose your platform with the switcher below:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-1&quot; role=&quot;tab&quot; aria-controls=&quot;windows-1&quot; aria-selected=&quot;true&quot;&gt;&lt;i class=&quot;fa fa-windows text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;Windows&lt;/a&gt;
  &lt;/li&gt;




  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linuxmacos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-macos-1&quot; role=&quot;tab&quot; aria-controls=&quot;linux-macos-1&quot; aria-selected=&quot;false&quot;&gt;&lt;i class=&quot;fa fa-linux text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;&lt;i class=&quot;fa fa-apple text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-1&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;p&gt;On Windows, you should use the &lt;a href=&quot;https://github.com/pyenv-win/pyenv-win&quot;&gt;&lt;code&gt;pyenv&lt;/code&gt; for Windows&lt;/a&gt; fork.
The documentation &lt;a href=&quot;https://github.com/pyenv-win/pyenv-win#installation&quot;&gt;guides you&lt;/a&gt; through the installation process.
Check out &lt;a href=&quot;https://realpython.com/python-coding-setup-windows/#installing-python-with-pyenv-for-windows&quot;&gt;Your Python Coding Environment on Windows: Setup Guide&lt;/a&gt; for more information about integrating &lt;code&gt;pyenv&lt;/code&gt; into your system.&lt;/p&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-macos-tab-1&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-macos-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;p&gt;On Linux and macOS, you can install &lt;code&gt;pyenv&lt;/code&gt; directly by following the instructions in the &lt;a href=&quot;https://github.com/pyenv/pyenv#installation&quot;&gt;documentation&lt;/a&gt;.
A good option is to use the &lt;a href=&quot;https://github.com/pyenv/pyenv-installer&quot;&gt;&lt;code&gt;pyenv-installer&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you want  an in-depth tutorial on how to use &lt;code&gt;pyenv&lt;/code&gt;, then check out &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;Managing Multiple Python Versions With &lt;code&gt;pyenv&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-pre-release/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-pre-release/ »&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: 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>Python and PyQt: Building a GUI Desktop Calculator</title>
      <id>https://realpython.com/python-pyqt-gui-calculator/</id>
      <link href="https://realpython.com/python-pyqt-gui-calculator/"/>
      <updated>2022-08-29T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to create graphical user interface (GUI) applications with Python and PyQt. Once you&#x27;ve covered the basics, you&#x27;ll build a fully functional desktop calculator that can respond to user events with concrete actions.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Even though web and mobile applications appear to have taken over the software development market, there’s still demand for traditional &lt;strong&gt;graphical user interface (GUI)&lt;/strong&gt; desktop applications. If you’re interested in building these kinds of applications in Python, then you’ll find a wide variety of libraries to choose from. They include &lt;a href=&quot;https://docs.python.org/3/library/tkinter.html&quot;&gt;Tkinter&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-gui-with-wxpython/&quot;&gt;wxPython&lt;/a&gt;, &lt;a href=&quot;https://www.riverbankcomputing.com/software/pyqt/intro&quot;&gt;PyQt&lt;/a&gt;, &lt;a href=&quot;https://wiki.qt.io/Qt_for_Python&quot;&gt;PySide&lt;/a&gt;, and a few others.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn the basics of building GUI desktop applications with Python and &lt;strong&gt;PyQt&lt;/strong&gt;.&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;graphical user interfaces&lt;/strong&gt; with Python and PyQt&lt;/li&gt;
&lt;li&gt;Connect the &lt;strong&gt;user’s events&lt;/strong&gt; on the app’s GUI with the &lt;strong&gt;app’s logic&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Organize a PyQt app using a proper &lt;strong&gt;project layout&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;fully functional GUI application&lt;/strong&gt; with PyQt&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this tutorial, you’ll create a calculator app with Python and PyQt. This short project will help you grasp the fundamentals and get you up and running with this GUI library.&lt;/p&gt;
&lt;p&gt;You can download the source code for the project and all examples in this tutorial by clicking on the link below:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Download Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/pyqt-calculator/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-pyqt-calculator&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the code that you’ll use&lt;/a&gt; to build a calculator in Python with PyQt in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-to-know-pyqt&quot;&gt;Getting to Know PyQt&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-pyqt&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;PyQt is a Python binding for &lt;a href=&quot;https://wiki.qt.io/About_Qt&quot;&gt;Qt&lt;/a&gt;, which is a set of &lt;a href=&quot;https://realpython.com/python-vs-cpp/&quot;&gt;C++&lt;/a&gt; libraries and development tools providing platform-independent abstractions for graphical user interfaces (GUIs). Qt also provides tools for networking, &lt;a href=&quot;https://realpython.com/python-pyqt-qthread/&quot;&gt;threads&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/regex-python/&quot;&gt;regular expressions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-pyqt-database/&quot;&gt;SQL databases&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Scalable_Vector_Graphics&quot;&gt;SVG&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/OpenGL&quot;&gt;OpenGL&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/XML&quot;&gt;XML&lt;/a&gt;, and many other powerful features.&lt;/p&gt;
&lt;p&gt;Developed by &lt;a href=&quot;https://riverbankcomputing.com&quot;&gt;RiverBank Computing Ltd&lt;/a&gt;, PyQt’s latest editions are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/&quot;&gt;PyQt5&lt;/a&gt;: An edition that’s built against Qt 5.x only&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt6/&quot;&gt;PyQt6&lt;/a&gt;: An edition that’s built against Qt 6.x only&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this tutorial, you’ll use PyQt6, as this version is the future of the library. From now on, be sure to consider any mention of PyQt as a reference to PyQt6.&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 want to dive deeper into the differences between these two versions of the library, then check out the &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt6/pyqt5_differences.html&quot;&gt;PyQt6 documentation&lt;/a&gt; on the topic.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;PyQt6 is based on &lt;a href=&quot;https://doc.qt.io/qt.html&quot;&gt;Qt v6&lt;/a&gt;. Therefore, it provides &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt6/sip-classes.html&quot;&gt;classes&lt;/a&gt; and tools for GUI creation, &lt;a href=&quot;https://realpython.com/python-xml-parser/&quot;&gt;XML&lt;/a&gt; handling, network communication, regular expressions, threads, SQL databases, web browsing, and other technologies available in Qt. PyQt6 implements binding for many Qt classes in a set of &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt6/module_index.html&quot;&gt;Python modules&lt;/a&gt;, which are organized in a top-level Python &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;package&lt;/a&gt; called &lt;code&gt;PyQt6&lt;/code&gt;. For PyQt6 to work, you need Python 3.6.1 or later.&lt;/p&gt;
&lt;p&gt;PyQt6 is compatible with Windows, Unix, Linux, macOS, iOS, and Android. This is an attractive feature if you’re looking for a GUI framework to develop multiplatform applications that have a native look and feel on each platform.&lt;/p&gt;
&lt;p&gt;PyQt6 is available under two licenses:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://riverbankcomputing.com/commercial/buy&quot;&gt;The Riverbank Commercial License&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.gnu.org/licenses/gpl-3.0.en.html&quot;&gt;The General Public License (GPL), version 3&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Your PyQt6 license must be compatible with your Qt license. If you use the GPL license, then your code must also use a GPL-compatible license. If you want to use PyQt6 to create commercial applications, then you need a commercial license for your 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; The &lt;a href=&quot;https://www.qt.io/&quot;&gt;Qt Company&lt;/a&gt; has developed and currently maintains its own Python binding for the Qt library. The Python library is called &lt;a href=&quot;https://wiki.qt.io/Qt_for_Python&quot;&gt;Qt for Python&lt;/a&gt; and is the official Qt for Python. Its Python package is called PySide.&lt;/p&gt;
&lt;p&gt;PyQt and PySide are both built on top of Qt. Their APIs are quite similar because they reflect the Qt API. That’s why porting PyQt code to PySide can be as simple as updating some imports. If you learn one of them, then you’ll be able to work with the other with minimal effort. If you want to dive deeper into the differences between these two libraries, then you can check out &lt;a href=&quot;https://www.pythonguis.com/faq/pyqt6-vs-pyside6/&quot;&gt;PyQt6 vs PySide6&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you need more information about PyQt6 licensing, then check out the license &lt;a href=&quot;https://www.riverbankcomputing.com/commercial/license-faq&quot;&gt;FAQs page&lt;/a&gt; on the project’s official documentation.&lt;/p&gt;
&lt;h2 id=&quot;installing-pyqt&quot;&gt;Installing PyQt&lt;a class=&quot;headerlink&quot; href=&quot;#installing-pyqt&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You have several options for installing PyQt on your system or development environment. The recommended option is to use to use binary &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt6/installation.html#installing-from-wheels&quot;&gt;wheels&lt;/a&gt;. Wheels are the standard way to install Python packages from the Python package index, &lt;a href=&quot;https://realpython.com/pypi-publish-python-package/&quot;&gt;PyPI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In any case, you need to consider that wheels for PyQt6 are only available for Python 3.6.1 and later. There are wheels for Linux, macOS, and Windows (64-bit).&lt;/p&gt;
&lt;p&gt;All of these wheels include copies of the corresponding Qt libraries, so you won’t need to install them separately.&lt;/p&gt;
&lt;p&gt;Another installation option is to build PyQt from source. This can be a bit complicated, so you might want to avoid it if possible. If you really need to build from source, then check out what the library’s &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt6/installation.html#building-and-installing-from-source&quot;&gt;documentation&lt;/a&gt; recommends in those cases.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-pyqt-gui-calculator/ »&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&#x27;s exec(): Execute Dynamically Generated Code</title>
      <id>https://realpython.com/python-exec/</id>
      <link href="https://realpython.com/python-exec/"/>
      <updated>2022-08-24T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use Python&#x27;s built-in exec() function to execute code that comes as either a string or a compiled code object.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s built-in &lt;strong&gt;&lt;code&gt;exec()&lt;/code&gt;&lt;/strong&gt; function allows you to execute arbitrary Python code from a string or compiled code input.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;exec()&lt;/code&gt; function can be handy when you need to run dynamically generated Python code, but it can be pretty dangerous if you use it carelessly. In this tutorial, you’ll learn not only how to use &lt;code&gt;exec()&lt;/code&gt;, but just as importantly, when it’s okay to use this function in your code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Work with Python’s built-in &lt;strong&gt;&lt;code&gt;exec()&lt;/code&gt;&lt;/strong&gt; function&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;exec()&lt;/code&gt; to execute &lt;strong&gt;code&lt;/strong&gt; that comes as &lt;strong&gt;strings&lt;/strong&gt; or &lt;strong&gt;compiled code&lt;/strong&gt; objects&lt;/li&gt;
&lt;li&gt;Assess and minimize the &lt;strong&gt;security risks&lt;/strong&gt; associated with using &lt;code&gt;exec()&lt;/code&gt; in your code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, you’ll write a few examples of using &lt;code&gt;exec()&lt;/code&gt; to solve different problems related to dynamic code execution.&lt;/p&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with Python’s &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;namespaces&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/&quot;&gt;scope&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;. You should also be familiar with some of Python’s &lt;a href=&quot;https://docs.python.org/3/library/functions.html&quot;&gt;built-in functions&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-exec-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-exec-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 explore use cases for the exec() function.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-to-know-pythons-exec&quot;&gt;Getting to Know Python’s &lt;code&gt;exec()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-pythons-exec&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s built-in &lt;a href=&quot;https://docs.python.org/3/library/functions.html#exec&quot;&gt;&lt;code&gt;exec()&lt;/code&gt;&lt;/a&gt; function allows you to execute any piece of Python code. With this function, you can execute &lt;strong&gt;dynamically generated code&lt;/strong&gt;. That’s the code that you read, auto-generate, or obtain during your program’s execution. Normally, it’s a string.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;exec()&lt;/code&gt; function takes a piece of code and executes it as your Python interpreter would. Python’s &lt;code&gt;exec()&lt;/code&gt; is like &lt;a href=&quot;https://realpython.com/python-eval-function/&quot;&gt;&lt;code&gt;eval()&lt;/code&gt;&lt;/a&gt; but even more powerful and prone to security issues. While &lt;code&gt;eval()&lt;/code&gt; can only evaluate &lt;a href=&quot;https://realpython.com/python-operators-expressions/&quot;&gt;expressions&lt;/a&gt;, &lt;code&gt;exec()&lt;/code&gt; can execute sequences of statements, as well as &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;imports&lt;/a&gt;, function calls and definitions, class definitions and instantiations, and more. Essentially, &lt;code&gt;exec()&lt;/code&gt; can execute an entire fully featured Python program.&lt;/p&gt;
&lt;p&gt;The signature of &lt;code&gt;exec()&lt;/code&gt; has the following form:&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;n&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;code&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;globals&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;locals&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;The function executes &lt;code&gt;code&lt;/code&gt;, which can be either a &lt;em&gt;string&lt;/em&gt; containing valid Python code or a &lt;em&gt;compiled&lt;/em&gt; code object.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Python is an &lt;a href=&quot;https://en.wikipedia.org/wiki/Interpreter_(computing)&quot;&gt;interpreted&lt;/a&gt; language instead of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Compiled_language&quot;&gt;compiled&lt;/a&gt; one. However, when you run some Python code, the interpreter translates it into &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-bytecode&quot;&gt;bytecode&lt;/a&gt;, which is an internal representation of a Python program in the &lt;a href=&quot;https://realpython.com/cpython-source-code-guide/&quot;&gt;CPython&lt;/a&gt; implementation. This intermediate translation is also referred to as &lt;strong&gt;compiled code&lt;/strong&gt; and is what Python’s &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-virtual-machine&quot;&gt;virtual machine&lt;/a&gt; executes.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If &lt;code&gt;code&lt;/code&gt; is a &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;string&lt;/a&gt;, then it’s &lt;em&gt;parsed as a suite of Python statements&lt;/em&gt;, which is then internally &lt;em&gt;compiled into bytecode&lt;/em&gt;, and finally &lt;em&gt;executed&lt;/em&gt;, unless a syntax error occurs during the parsing or compilation step. If &lt;code&gt;code&lt;/code&gt; holds a compiled code object, then it’s executed directly, making the process a bit more efficient.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;globals&lt;/code&gt; and &lt;code&gt;locals&lt;/code&gt; arguments allow you to provide dictionaries representing the &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/#modules-the-global-scope&quot;&gt;global&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/#functions-the-local-scope&quot;&gt;local&lt;/a&gt; namespaces in which &lt;code&gt;exec()&lt;/code&gt; will run the target code.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;exec()&lt;/code&gt; function’s &lt;a href=&quot;https://realpython.com/python-return-statement/&quot;&gt;return&lt;/a&gt; value is &lt;a href=&quot;https://realpython.com/null-in-python/&quot;&gt;&lt;code&gt;None&lt;/code&gt;&lt;/a&gt;, probably because not every piece of code has a final, unique, and concrete result. It may just have some &lt;a href=&quot;https://en.wikipedia.org/wiki/Side_effect_(computer_science)&quot;&gt;side effects&lt;/a&gt;. This behavior notably differs from &lt;code&gt;eval()&lt;/code&gt;, which returns the result of the evaluated expression.&lt;/p&gt;
&lt;p&gt;To get an initial feeling of how &lt;code&gt;exec()&lt;/code&gt; works, you can create a rudimentary Python interpreter with two lines of code:&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;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&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;-&amp;gt;&amp;gt; &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;-&amp;gt;&amp;gt; print(&quot;Hello, World!&quot;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;-&amp;gt;&amp;gt; import this&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The Zen of Python, by Tim Peters&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;Beautiful is better than ugly.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Explicit is better than implicit.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Simple is better than complex.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    ...&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;-&amp;gt;&amp;gt; x = 10&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;-&amp;gt;&amp;gt; if 1 &amp;lt;= x &amp;lt;= 10: print(f&quot;{x} is between 1 and 10&quot;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;10 is between 1 and 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you use an infinite &lt;a href=&quot;https://realpython.com/python-while-loop/&quot;&gt;&lt;code&gt;while&lt;/code&gt;&lt;/a&gt; loop to mimic the behavior of a Python &lt;a href=&quot;https://realpython.com/interacting-with-python/#starting-the-interpreter&quot;&gt;interpreter&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop&quot;&gt;REPL&lt;/a&gt;. Inside the loop, you use &lt;a href=&quot;https://docs.python.org/3/library/functions.html#input&quot;&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/a&gt; to get the user’s input at the command line. Then you use &lt;code&gt;exec()&lt;/code&gt; to process and run the input.&lt;/p&gt;
&lt;p&gt;This example showcases what’s arguably the main use case of &lt;code&gt;exec()&lt;/code&gt;: &lt;em&gt;executing code that comes to you as a string.&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You’ve learned that using &lt;code&gt;exec()&lt;/code&gt; can imply security risks. Now that you’ve seen the main use case of &lt;code&gt;exec()&lt;/code&gt;, what do you think those security risks might be? You’ll find the answer later in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You’ll commonly use &lt;code&gt;exec()&lt;/code&gt; when you need to dynamically run code that comes as a string. For example, you can write a program that generates strings containing valid Python code. You can build these strings from parts that you obtain at different moments in your program’s execution. You can also use the user’s input or any other input source to construct these strings.&lt;/p&gt;
&lt;p&gt;Once you’ve built the target code as strings, then you can use &lt;code&gt;exec()&lt;/code&gt; to execute them as you would execute any Python code.&lt;/p&gt;
&lt;p&gt;In this situation, you can rarely be certain of what your strings will contain. That’s one reason why &lt;code&gt;exec()&lt;/code&gt; implies serious security risks. This is particularly true if you’re using untrusted input sources, like a user’s direct input, in building your code. &lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-exec/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-exec/ »&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 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>How to Check if a Python String Contains a Substring</title>
      <id>https://realpython.com/python-string-contains-substring/</id>
      <link href="https://realpython.com/python-string-contains-substring/"/>
      <updated>2022-08-22T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn the best way to check whether a Python string contains a substring. You&#x27;ll also learn about idiomatic ways to inspect the substring further, match substrings with conditions using regular expressions, and search for substrings in pandas.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’re new to programming or come from a programming language other than Python, you may be looking for the best way to check whether a string contains another string in Python.&lt;/p&gt;
&lt;p&gt;Identifying such &lt;a href=&quot;https://en.wikipedia.org/wiki/Substring&quot;&gt;substrings&lt;/a&gt; comes in handy when you’re working with &lt;a href=&quot;https://realpython.com/read-write-files-python/&quot;&gt;text content from a file&lt;/a&gt; or after you’ve &lt;a href=&quot;https://realpython.com/python-input-output/&quot;&gt;received user input&lt;/a&gt;. You may want to perform different actions in your program depending on whether a substring is present or not.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll focus on the most Pythonic way to tackle this task, using the &lt;strong&gt;membership operator &lt;code&gt;in&lt;/code&gt;&lt;/strong&gt;. Additionally, you’ll learn how to &lt;strong&gt;identify the right string methods&lt;/strong&gt; for related, but different, use cases.&lt;/p&gt;
&lt;p&gt;Finally, you’ll also learn how to &lt;strong&gt;find substrings in pandas columns&lt;/strong&gt;. This is helpful if you need to search through data from a CSV file. You &lt;em&gt;could&lt;/em&gt; use the approach that you’ll learn in the next section, but if you’re working with &lt;strong&gt;tabular data&lt;/strong&gt;, it’s best to load the data into a pandas DataFrame and &lt;a href=&quot;#find-a-substring-in-a-pandas-dataframe-column&quot;&gt;search for substrings in pandas&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-string-contains-substring-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-string-contains-substring-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the sample code&lt;/a&gt; that you’ll use to check if a string contains a substring.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-confirm-that-a-python-string-contains-another-string&quot;&gt;How to Confirm That a Python String Contains Another String&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-confirm-that-a-python-string-contains-another-string&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you need to check whether a string contains a substring, use Python’s membership operator &lt;code&gt;in&lt;/code&gt;. In Python, this is the recommended way to confirm the existence of a substring in a string:&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;raw_file_content&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&quot;Hi there and welcome.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;This is a special hidden file with a SECRET secret.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;I don&#x27;t want to tell you The Secret,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;but I do want to secretly tell you that I have one.&quot;&quot;&quot;&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;secret&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;raw_file_content&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;in&lt;/code&gt; membership operator gives you a quick and readable way to check whether a substring is present in a string. You may notice that the line of code almost reads like English.&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 want to check whether the substring is &lt;em&gt;not&lt;/em&gt; in the string, then you can use &lt;code&gt;not in&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;s2&quot;&gt;&quot;secret&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;raw_file_content&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Because the substring &lt;code&gt;&quot;secret&quot;&lt;/code&gt; is present in &lt;code&gt;raw_file_content&lt;/code&gt;, the &lt;code&gt;not in&lt;/code&gt; operator returns &lt;code&gt;False&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;When you use &lt;code&gt;in&lt;/code&gt;, the expression returns a &lt;a href=&quot;https://realpython.com/python-boolean/&quot;&gt;Boolean value&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;True&lt;/code&gt; if Python found the substring&lt;/li&gt;
&lt;li&gt;&lt;code&gt;False&lt;/code&gt; if Python didn’t find the substring&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can use this intuitive syntax in &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional statements&lt;/a&gt; to make decisions in your code:&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;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;secret&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;raw_file_content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;   &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Found!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Found!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this code snippet, you use the membership operator to check whether &lt;code&gt;&quot;secret&quot;&lt;/code&gt; is a substring of &lt;code&gt;raw_file_content&lt;/code&gt;. If it is, then you’ll print a message to the terminal. Any indented code will only execute if the Python string that you’re checking contains the substring that you provide.&lt;/p&gt;
&lt;p&gt;The membership operator &lt;code&gt;in&lt;/code&gt; is your best friend if you just need to check whether a Python string contains a substring.&lt;/p&gt;
&lt;p&gt;However, what if you want to know more about the substring? If you read through the text stored in &lt;code&gt;raw_file_content&lt;/code&gt;, then you’ll notice that the substring occurs more than once, and even in different variations!&lt;/p&gt;
&lt;p&gt;Which of these occurrences did Python find? Does capitalization make a difference? How often does the substring show up in the text? And what’s the location of these substrings? If you need the answer to any of these questions, then keep on reading.&lt;/p&gt;
&lt;h2 id=&quot;generalize-your-check-by-removing-case-sensitivity&quot;&gt;Generalize Your Check by Removing Case Sensitivity&lt;a class=&quot;headerlink&quot; href=&quot;#generalize-your-check-by-removing-case-sensitivity&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python strings are case sensitive. If the substring that you provide uses different capitalization than the same word in your text, then Python won’t find it. For example, if you check for the lowercase word &lt;code&gt;&quot;secret&quot;&lt;/code&gt; on a &lt;a href=&quot;https://realpython.com/python-strings/#case-conversion&quot;&gt;title-case version&lt;/a&gt; of the original text, the membership operator check returns &lt;code&gt;False&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;title_cased_file_content&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&quot;Hi There And Welcome.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;This Is A Special Hidden File With A Secret Secret.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;I Don&#x27;t Want To Tell You The Secret,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;But I Do Want To Secretly Tell You That I Have One.&quot;&quot;&quot;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;secret&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title_cased_file_content&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Despite the fact that the word &lt;em&gt;secret&lt;/em&gt; appears multiple times in the title-case text &lt;code&gt;title_cased_file_content&lt;/code&gt;, it &lt;em&gt;never&lt;/em&gt; shows up in all lowercase. That’s why the check that you perform with the membership operator returns &lt;code&gt;False&lt;/code&gt;. Python can’t find the all-lowercase string &lt;code&gt;&quot;secret&quot;&lt;/code&gt; in the provided text.&lt;/p&gt;
&lt;p&gt;Humans have a different approach to language than computers do. This is why you’ll often want to disregard capitalization when you check whether a string contains a substring in Python.&lt;/p&gt;
&lt;p&gt;You can generalize your substring check by converting the whole input text to lowercase:&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;file_content&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title_cased_file_content&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;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;file_content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;hi there and welcome.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;this is a special hidden file with a secret secret.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;i don&#x27;t want to tell you the secret,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;but i do want to secretly tell you that i have one.&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;secret&quot;&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file_content&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&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-string-contains-substring/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-string-contains-substring/ »&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 #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>
  
    <entry>
      <title>Exploring Special Function Parameters</title>
      <id>https://realpython.com/courses/special-function-parameters/</id>
      <link href="https://realpython.com/courses/special-function-parameters/"/>
      <updated>2022-08-09T14:00:00+00:00</updated>
      <summary>In this Code Conversation video course, you&#x27;ll explore special function parameters that allow for positional-only arguments, keyword-only arguments, or a combination of the two.</summary>
      <content type="html">
        &lt;p&gt;Have you ever come across the forward slash (&lt;code&gt;/&lt;/code&gt;) and asterisk (&lt;code&gt;*&lt;/code&gt;) symbols in the documentation for your favorite libraries? These represent special parameters, which tell you what kinds of arguments you can use to call a given function. In Python, these parameters can help you ensure that your functions are used correctly.&lt;/p&gt;
&lt;p&gt;Maybe you&amp;rsquo;re a regular at Real Python&amp;rsquo;s weekly &lt;a href=&quot;https://realpython.com/office-hours/&quot;&gt;Office Hours&lt;/a&gt; meetup, or perhaps you&amp;rsquo;re curious about what happens there. You&amp;rsquo;ll get a glimpse in this Code Conversation, which answers one participant&amp;rsquo;s question of how to interpret and apply special function parameters in writing and calling functions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this Code Conversation video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set &lt;strong&gt;default values&lt;/strong&gt; for arguments&lt;/li&gt;
&lt;li&gt;Write &lt;strong&gt;positional-only&lt;/strong&gt;, &lt;strong&gt;keyword-only&lt;/strong&gt;, and &lt;strong&gt;combined&lt;/strong&gt; functions&lt;/li&gt;
&lt;li&gt;Refer to the &lt;strong&gt;forward slash (&lt;code&gt;/&lt;/code&gt;)&lt;/strong&gt; and &lt;strong&gt;asterisk (&lt;code&gt;*&lt;/code&gt;)&lt;/strong&gt; accurately&lt;/li&gt;
&lt;li&gt;Use special function parameters in &lt;strong&gt;real-world code&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 #120: Inspiring Young People to Learn Python With Mission Encodeable</title>
      <id>https://realpython.com/podcasts/rpp/120/</id>
      <link href="https://realpython.com/podcasts/rpp/120/"/>
      <updated>2022-08-05T12:00:00+00:00</updated>
      <summary>Is there someone in your life you&#x27;d like to inspire to learn Python? Mission Encodeable is a website designed to teach people to code, built by two high-school students. This week on the show, Anna and Harry Wake talk about creating their site and motivating people to start coding.</summary>
      <content type="html">
        &lt;p&gt;Is there someone in your life you&#x27;d like to inspire to learn Python? Mission Encodeable is a website designed to teach people to code, built by two high-school students. This week on the show, Anna and Harry Wake talk about creating their site and motivating people to start coding.&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: Finding and Fixing Code Bugs</title>
      <id>https://realpython.com/courses/python-basics-code-bugs/</id>
      <link href="https://realpython.com/courses/python-basics-code-bugs/"/>
      <updated>2022-08-02T14:00:00+00:00</updated>
      <summary>In this Python Basics video course, you&#x27;ll learn how to identify and fix logic errors, or bugs, in your Python code. You&#x27;ll use the built-in debugging tools in Python&#x27;s Integrated Development and Learning Environment to practice locating and resolving bugs in an example function.</summary>
      <content type="html">
        &lt;p&gt;Everyone makes mistakes—even seasoned professional developers!&lt;/p&gt;
&lt;p&gt;IDLE is pretty good at catching mistakes like syntax errors and run-time errors, but there&amp;rsquo;s a third type of error that you may have already experienced. &lt;strong&gt;Logic errors&lt;/strong&gt; occur when an otherwise valid program doesn&amp;rsquo;t do what was intended.&lt;/p&gt;
&lt;p&gt;Logic errors cause unexpected behaviors called &lt;strong&gt;bugs&lt;/strong&gt;. Removing bugs is called &lt;strong&gt;debugging&lt;/strong&gt;, and a &lt;strong&gt;debugger&lt;/strong&gt; is a tool that helps you hunt down bugs and understand why they&amp;rsquo;re happening.&lt;/p&gt;
&lt;p&gt;Knowing how to find and fix bugs in your code is a skill that you will use for your entire coding career!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this &lt;em&gt;Python Basics&lt;/em&gt; video course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn how to use &lt;strong&gt;IDLE&amp;rsquo;s Debug Control&lt;/strong&gt; window&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Practice debugging&lt;/strong&gt; on a buggy function&lt;/li&gt;
&lt;li&gt;Learn &lt;strong&gt;alternative methods&lt;/strong&gt; for debugging your code&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 #119: Natural Language Processing and How ML Models Understand Text</title>
      <id>https://realpython.com/podcasts/rpp/119/</id>
      <link href="https://realpython.com/podcasts/rpp/119/"/>
      <updated>2022-07-29T12:00:00+00:00</updated>
      <summary>How do you process and classify text documents in Python? What are the fundamental techniques and building blocks for Natural Language Processing (NLP)? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, talks about how machine learning (ML) models understand text.</summary>
      <content type="html">
        &lt;p&gt;How do you process and classify text documents in Python? What are the fundamental techniques and building blocks for Natural Language Processing (NLP)? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, talks about how machine learning (ML) models understand 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>
  
    <entry>
      <title>Managing Attributes With Python&#x27;s property()</title>
      <id>https://realpython.com/courses/property-python/</id>
      <link href="https://realpython.com/courses/property-python/"/>
      <updated>2022-07-26T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to create managed attributes, also known as properties, using Python&#x27;s property() in your custom classes.</summary>
      <content type="html">
        &lt;p&gt;With Python&amp;rsquo;s &lt;a href=&quot;https://docs.python.org/3/library/functions.html#property&quot;&gt;&lt;code&gt;property()&lt;/code&gt;&lt;/a&gt;, you can create &lt;strong&gt;managed attributes&lt;/strong&gt; in your classes. You can use managed attributes, also known as &lt;strong&gt;properties&lt;/strong&gt;, when you need to modify their internal implementation without changing the public &lt;a href=&quot;https://en.wikipedia.org/wiki/API&quot;&gt;API&lt;/a&gt; of the class. Providing stable APIs can help you avoid breaking your users&amp;rsquo; code when they rely on your classes and objects.&lt;/p&gt;
&lt;p&gt;Properties are arguably the most popular way to create managed attributes quickly and in the purest &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;Pythonic&lt;/a&gt; style.&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;managed attributes&lt;/strong&gt; or &lt;strong&gt;properties&lt;/strong&gt; in your classes&lt;/li&gt;
&lt;li&gt;Perform &lt;strong&gt;lazy attribute evaluation&lt;/strong&gt; and provide &lt;strong&gt;computed attributes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Avoid &lt;strong&gt;setter&lt;/strong&gt; and &lt;strong&gt;getter&lt;/strong&gt; methods to make your classes more Pythonic&lt;/li&gt;
&lt;li&gt;Create &lt;strong&gt;read-only&lt;/strong&gt;, &lt;strong&gt;read-write&lt;/strong&gt;, and &lt;strong&gt;write-only&lt;/strong&gt; properties&lt;/li&gt;
&lt;li&gt;Create consistent and &lt;strong&gt;backwards-compatible APIs&lt;/strong&gt; for your classes&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 #118: Creating Documentation With MkDocs &amp; When to Use a Python dict</title>
      <id>https://realpython.com/podcasts/rpp/118/</id>
      <link href="https://realpython.com/podcasts/rpp/118/"/>
      <updated>2022-07-22T12:00:00+00:00</updated>
      <summary>How do you start building your project documentation? What if you had a tool that could do the heavy lifting and automatically write large portions directly from your code? 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;How do you start building your project documentation? What if you had a tool that could do the heavy lifting and automatically write large portions directly from your code? 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>Using the Python not Operator</title>
      <id>https://realpython.com/courses/using-not-operator/</id>
      <link href="https://realpython.com/courses/using-not-operator/"/>
      <updated>2022-07-19T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn how Python&#x27;s &quot;not&quot; operator works and how to use it in your code. You&#x27;ll get to know its features and see what kind of programming problems you can solve by using &quot;not&quot; in Python.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;not&lt;/code&gt;&lt;/strong&gt; operator allows you to invert the &lt;strong&gt;truth value&lt;/strong&gt; of Boolean expressions and objects. You can use this operator in Boolean contexts, such as &lt;code&gt;if&lt;/code&gt; statements and &lt;code&gt;while&lt;/code&gt; loops. It also works in non-Boolean contexts, which allows you to invert the truth value of your variables.&lt;/p&gt;
&lt;p&gt;Using the &lt;code&gt;not&lt;/code&gt; operator effectively will help you write accurate negative Boolean expressions to control the flow of execution in your programs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;not&lt;/code&gt;&lt;/strong&gt; operator works&lt;/li&gt;
&lt;li&gt;How to use the &lt;code&gt;not&lt;/code&gt; operator in &lt;strong&gt;Boolean&lt;/strong&gt; and &lt;strong&gt;non-Boolean contexts&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to use the &lt;strong&gt;&lt;code&gt;operator.not_()&lt;/code&gt;&lt;/strong&gt; function to perform logical negation&lt;/li&gt;
&lt;li&gt;How and when to avoid unnecessary &lt;strong&gt;negative logic&lt;/strong&gt; in your code&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 #117: Measuring Python Code Quality, Simplicity, and Maintainability</title>
      <id>https://realpython.com/podcasts/rpp/117/</id>
      <link href="https://realpython.com/podcasts/rpp/117/"/>
      <updated>2022-07-15T12:00:00+00:00</updated>
      <summary>How maintainable is your Python code? Is it possible to hold the code for your functions in your head? When is it appropriate to use measurements in a code review? This week on the show, Reka Horvath and Ben Martineau from Sourcery are here to discuss their recent PyCon talk, &quot;Actionable insights vs ranking: How to use and how NOT to use code quality metrics.&quot;</summary>
      <content type="html">
        &lt;p&gt;How maintainable is your Python code? Is it possible to hold the code for your functions in your head? When is it appropriate to use measurements in a code review? This week on the show, Reka Horvath and Ben Martineau from Sourcery are here to discuss their recent PyCon talk, &quot;Actionable insights vs ranking: How to use and how NOT to use code quality metrics.&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>
  

</feed>
