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

  <title>Real Python</title>
  <link href="https://realpython.com/atom.xml" rel="self"/>
  <link href="https://realpython.com/"/>
  <updated>2023-07-31T14:00:00+00:00</updated>
  <id>https://realpython.com/</id>
  <author>
    <name>Real Python</name>
  </author>

  
    <entry>
      <title>How to Download Files From URLs With Python</title>
      <id>https://realpython.com/python-download-file-from-url/</id>
      <link href="https://realpython.com/python-download-file-from-url/"/>
      <updated>2023-07-31T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll find the right tools to help you download files from URLs with Python and manage the data retrieval process. You&#x27;ll cover data streaming, thread pools, and asynchronous downloads.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When it comes to file retrieval, Python offers a robust set of tools and packages that are useful in a variety of applications, from web scraping to automating scripts and analyzing retrieved data. Downloading files from a URL programmatically is a useful skill to learn for various programming and data projects and workflows. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Download&lt;/strong&gt; files from the Web using the standard library as well as third-party libraries in Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stream data&lt;/strong&gt; to download large files in manageable chunks&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;parallel&lt;/strong&gt; downloads using a pool of threads&lt;/li&gt;
&lt;li&gt;Perform &lt;strong&gt;asynchronous&lt;/strong&gt; downloads to fetch multiple files in bulk&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, you’ll be downloading a range of economic data from the World Bank Open Data platform. To get started on this example project, go ahead and grab the sample code 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;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-download-file-from-url-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-download-file-from-url-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your sample code&lt;/a&gt; for downloading files from the Web with Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;facilitating-file-downloads-with-python&quot;&gt;Facilitating File Downloads With Python&lt;a class=&quot;headerlink&quot; href=&quot;#facilitating-file-downloads-with-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While it’s possible to download files from &lt;a href=&quot;https://en.wikipedia.org/wiki/URL&quot;&gt;URLs&lt;/a&gt; using traditional &lt;a href=&quot;https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x8751.htm&quot;&gt;command-line tools&lt;/a&gt;, Python provides several libraries that facilitate file retrieval. Using Python to download files offers several advantages. &lt;/p&gt;
&lt;p&gt;One advantage is &lt;strong&gt;flexibility&lt;/strong&gt;, as Python has a rich ecosystem of libraries, including ones that offer efficient ways to handle different file formats, protocols, and authentication methods. You can choose the most suitable Python tools to accomplish the task at hand and fulfill your specific requirements, whether you’re downloading from a plain-text &lt;a href=&quot;https://realpython.com/python-interview-problem-parsing-csv-files/&quot;&gt;CSV&lt;/a&gt; file or a complex binary file.&lt;/p&gt;
&lt;p&gt;Another reason is &lt;strong&gt;portability&lt;/strong&gt;. You may encounter situations where you’re working on cross-platform applications. In such cases, using Python is a good choice because it’s a cross-platform programming language. This means that Python code can run consistently across different operating systems, such as Windows, Linux, and macOS. &lt;/p&gt;
&lt;p&gt;Using Python also offers the possibility of &lt;strong&gt;automating your processes&lt;/strong&gt;, saving you time and effort. Some examples include automating retries if a download fails, retrieving and saving multiple files from URLs, and processing and storing your data in designated locations.&lt;/p&gt;
&lt;p&gt;These are just a few reasons why downloading files using Python is better than using traditional command-line tools. Depending on your project requirements, you can choose the approach and library that best suits your needs. In this tutorial, you’ll learn approaches to some common scenarios requiring file retrievals.&lt;/p&gt;
&lt;h2 id=&quot;downloading-a-file-from-a-url-in-python&quot;&gt;Downloading a File From a URL in Python&lt;a class=&quot;headerlink&quot; href=&quot;#downloading-a-file-from-a-url-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this section, you’ll learn the basics of downloading a &lt;a href=&quot;https://realpython.com/python-zipfile/&quot;&gt;ZIP file&lt;/a&gt; containing &lt;a href=&quot;https://en.wikipedia.org/wiki/Gross_domestic_product&quot;&gt;gross domestic product (GDP)&lt;/a&gt; data from the &lt;a href=&quot;https://data.worldbank.org/&quot;&gt;World Bank Open Data&lt;/a&gt; platform. You’ll use two common tools in Python, &lt;code&gt;urllib&lt;/code&gt; and &lt;code&gt;requests&lt;/code&gt;, to download &lt;strong&gt;GDP by country&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;While the &lt;code&gt;urllib&lt;/code&gt; package comes with Python in its standard library, it has some limitations. So, you’ll also learn to use a popular third-party library, &lt;code&gt;requests&lt;/code&gt;, that offers more features for making &lt;a href=&quot;https://en.wikipedia.org/wiki/HTTP&quot;&gt;HTTP&lt;/a&gt; requests. Later in the tutorial, you’ll see additional functionalities and use cases.&lt;/p&gt;
&lt;h3 id=&quot;using-urllib-from-the-standard-library&quot;&gt;Using &lt;code&gt;urllib&lt;/code&gt; From the Standard Library&lt;a class=&quot;headerlink&quot; href=&quot;#using-urllib-from-the-standard-library&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Python ships with a package called &lt;a href=&quot;https://realpython.com/urllib-request/&quot;&gt;&lt;code&gt;urllib&lt;/code&gt;&lt;/a&gt;, which provides a convenient way to interact with web resources. It has a straightforward and user-friendly interface, making it suitable for quick prototyping and smaller projects. With &lt;code&gt;urllib&lt;/code&gt;, you can perform different tasks dealing with network communication, such as parsing URLs, sending HTTP requests, downloading files, and handling errors related to network operations.&lt;/p&gt;
&lt;p&gt;As a standard library package, &lt;code&gt;urllib&lt;/code&gt; has no external dependencies and doesn’t require installing additional packages, making it a convenient choice. For the same reason, it’s readily accessible for development and deployment. It’s also cross-platform compatible, meaning you can write and run code seamlessly using the &lt;code&gt;urllib&lt;/code&gt; package across different operating systems without additional dependencies or configuration.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;urllib&lt;/code&gt; package is also very versatile. It integrates well with other &lt;a href=&quot;https://realpython.com/python-import/#modules&quot;&gt;modules&lt;/a&gt; in the Python standard library, such as &lt;code&gt;re&lt;/code&gt; for building and manipulating &lt;a href=&quot;https://realpython.com/regex-python/&quot;&gt;regular expressions&lt;/a&gt;, as well as &lt;code&gt;json&lt;/code&gt; for &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;working with JSON data&lt;/a&gt;. The latter is particularly handy when you need to consume JSON &lt;a href=&quot;https://realpython.com/python-api/&quot;&gt;APIs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In addition, you can extend the &lt;code&gt;urllib&lt;/code&gt; package and use it with other third-party libraries, like &lt;a href=&quot;https://realpython.com/python-requests/&quot;&gt;&lt;code&gt;requests&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/beautiful-soup-web-scraper-python/&quot;&gt;&lt;code&gt;BeautifulSoup&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/web-scraping-with-scrapy-and-mongodb/&quot;&gt;&lt;code&gt;Scrapy&lt;/code&gt;&lt;/a&gt;. This offers the possibility for more advanced operations in &lt;a href=&quot;https://realpython.com/python-web-scraping-practical-introduction/&quot;&gt;web scraping&lt;/a&gt; and interacting with web APIs.&lt;/p&gt;
&lt;p&gt;To download a file from a URL using the &lt;code&gt;urllib&lt;/code&gt; package, you can call &lt;code&gt;urlretrieve()&lt;/code&gt; from the &lt;code&gt;urllib.request&lt;/code&gt; module. This function fetches a web resource from the specified URL and then saves the response to a local file. To start, import &lt;code&gt;urlretrieve()&lt;/code&gt; from &lt;code&gt;urlllib.request&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;urllib.request&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlretrieve&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, define the URL that you want to retrieve data from. If you don’t specify a path to a local file where you want to save the data, then the function will create a &lt;a href=&quot;https://realpython.com/working-with-files-in-python/#making-temporary-files-and-directories&quot;&gt;temporary file&lt;/a&gt; for you. Since you know that you’ll be downloading a ZIP file from that URL, go ahead and provide an optional path to the target file:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;https://api.worldbank.org/v2/en/indicator/&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;NY.GDP.MKTP.CD?downloadformat=csv&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;gdp_by_country.zip&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Because your URL is quite long, you rely on Python’s &lt;strong&gt;implicit concatenation&lt;/strong&gt; by splitting the string literal over multiple lines inside parentheses. The Python interpreter will automatically join the separate strings on different lines into a single string. You also define the location where you wish to save the file. When you only provide a filename without a path, Python will save the resulting file in your &lt;a href=&quot;https://en.wikipedia.org/wiki/Working_directory&quot;&gt;current working directory&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then, you can download and save the file by calling &lt;code&gt;urlretrieve()&lt;/code&gt; and passing in the URL and optionally your filename:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-download-file-from-url/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-download-file-from-url/ »&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 #166: Differentiating the Versions of Python &amp; Unlocking IPython&#x27;s Magic</title>
      <id>https://realpython.com/podcasts/rpp/166/</id>
      <link href="https://realpython.com/podcasts/rpp/166/"/>
      <updated>2023-07-28T12:00:00+00:00</updated>
      <summary>What are all the different versions of Python? You may have heard of Cython, Brython, PyPy, or others and wondered where they fit into the Python landscape. 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;What are all the different versions of Python? You may have heard of Cython, Brython, PyPy, or others and wondered where they fit into the Python landscape. This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python 3.12 Preview: More Intuitive and Consistent F-Strings</title>
      <id>https://realpython.com/python312-f-strings/</id>
      <link href="https://realpython.com/python312-f-strings/"/>
      <updated>2023-07-26T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll preview one of the upcoming features of Python 3.12, which introduces a new f-string syntax formalization and implementation. The new implementation lifts some restrictions and limitations that affect f-string literals in Python versions lower than 3.12.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Every new Python version brings many changes, updates, fixes, and new features. Python 3.12 will be the next minor version and is now in the &lt;a href=&quot;https://realpython.com/python-news-may-2023/#python-312-in-beta&quot;&gt;beta phase&lt;/a&gt;. In this version, the core team has been working intensely to formalize and improve the syntax and behavior of one of the most popular Python features: &lt;strong&gt;f-strings&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;F-strings, short for &lt;strong&gt;formatted strings&lt;/strong&gt;, are string literals prefixed by either a lowercase or uppercase letter F. These strings provide a concise and clean syntax that allows the &lt;strong&gt;interpolation&lt;/strong&gt; of variables and expressions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Limitations&lt;/strong&gt; of f-strings in Python versions before 3.12&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Advantages&lt;/strong&gt; of formalizing the f-string syntax&lt;/li&gt;
&lt;li&gt;New capabilities and &lt;strong&gt;features&lt;/strong&gt; of f-strings in Python 3.12&lt;/li&gt;
&lt;li&gt;Formalization as the key to &lt;strong&gt;better error messages&lt;/strong&gt; for f-strings&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should be familiar with the &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;string&lt;/a&gt; data type, as well as with &lt;a href=&quot;https://realpython.com/python-f-strings/&quot;&gt;f-strings&lt;/a&gt; and string &lt;a href=&quot;https://realpython.com/python-strings/#interpolating-variables-into-a-string&quot;&gt;interpolation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You’ll find many other new features, improvements, and optimizations in Python 3.12. The most relevant ones include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-error-messages/&quot;&gt;Ever better error messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-perf-profiler/&quot;&gt;Support for the Linux &lt;code&gt;perf&lt;/code&gt; profiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Support for subinterpreters&lt;/li&gt;
&lt;li&gt;Improved static typing features&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Go ahead and check out &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html&quot;&gt;what’s new&lt;/a&gt; in the changelog for more details on these and other features.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-312-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-312-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your sample code&lt;/a&gt; for a sneak peek at Python 3.12, coming in October 2023.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;f-strings-had-some-limitations-before-python-312&quot;&gt;F-Strings Had Some Limitations Before Python 3.12&lt;a class=&quot;headerlink&quot; href=&quot;#f-strings-had-some-limitations-before-python-312&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can use Python’s &lt;a href=&quot;https://realpython.com/python-f-strings/&quot;&gt;f-strings&lt;/a&gt; for string formatting and interpolation. An f-string is a string &lt;a href=&quot;https://en.wikipedia.org/wiki/Literal_(computer_programming)&quot;&gt;literal&lt;/a&gt; prefixed with the letter F, either in uppercase or lowercase. This kind of literal lets you interpolate &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; and expressions, which Python evaluates to produce the final string.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.6.html#pep-498-formatted-string-literals&quot;&gt;F-strings&lt;/a&gt; have gained a lot of popularity in the Python community since their introduction in Python 3.6. People have embraced them with enthusiasm, turning them into a standard in modern Python programming. The reasons? They provide a concise and readable syntax that allows you to format strings and interpolate variables and expressions without needing the &lt;a href=&quot;https://realpython.com/python-formatted-output/#the-python-string-format-method&quot;&gt;&lt;code&gt;.format()&lt;/code&gt;&lt;/a&gt; method or the &lt;a href=&quot;https://realpython.com/python-string-formatting/#1-old-style-string-formatting-operator&quot;&gt;old-style string formatting operator (&lt;code&gt;%&lt;/code&gt;)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, to introduce f-strings, the &lt;a href=&quot;https://realpython.com/cpython-source-code-guide/&quot;&gt;CPython&lt;/a&gt; core development team had to decide how to implement them, especially how to parse them. As a result, f-strings came with their own parsing code. In other words, CPython has a dedicated parser for f-strings. Because of this, the f-string grammar isn’t part of the &lt;a href=&quot;https://docs.python.org/3/reference/lexical_analysis.html#f-strings&quot;&gt;official Python grammar&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;From the core developers’ point of view, this implementation decision implies considerable maintenance costs because they have to manually maintain a separate parser. On the other hand, not being part of the official grammar means that other Python implementations, such as &lt;a href=&quot;https://realpython.com/pypy-faster-python/&quot;&gt;PyPy&lt;/a&gt;, can’t know if they’ve implemented f-strings correctly.&lt;/p&gt;
&lt;p&gt;However, the most important burden is on the user’s side. From the user’s perspective, the current f-string implementation imposes some limitations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reusing &lt;strong&gt;quotes&lt;/strong&gt; or string delimiters isn’t possible.&lt;/li&gt;
&lt;li&gt;Embedding &lt;strong&gt;backslashes&lt;/strong&gt; isn’t possible, which means you can’t use &lt;a href=&quot;https://en.wikipedia.org/wiki/Escape_character&quot;&gt;escape characters&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Adding inline &lt;strong&gt;comments&lt;/strong&gt; is forbidden.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nesting&lt;/strong&gt; of f-strings is limited to the available quoting variations in Python.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;https://peps.python.org/pep-0536/&quot;&gt;PEP 536&lt;/a&gt; lists these limitations. However, exploring them with a few small examples will help you understand how they can affect your use of f-strings in your Python code.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The examples that you’ll see in this section use Python 3.11. If you have a lower Python version installed, then you may get different output.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;First, say that you need to interpolate a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt; key in an f-string. If you try the following code, then you’ll get an error:&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;employee&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;John Doe&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;s2&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;35&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;s2&quot;&gt;&quot;job&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Python Developer&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &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;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Employee: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;employee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Employee: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;employee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                           &lt;/span&gt;&lt;span class=&quot;pm&quot;&gt;^^^^&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;SyntaxError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;f-string: unmatched &#x27;[&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you try to interpolate the employee name in your f-strings. However, you get an error because the double quotes around the &lt;code&gt;&quot;name&quot;&lt;/code&gt; key break the string literal. To work around this, you need to use a different type of quotation mark to delimit the key:&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;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Employee: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;employee&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;name&#x27;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Employee: John Doe&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now you use double quotes for the f-string and single quotes for the dictionary key. Your code works now, but having to switch quotes can get annoying at times.&lt;/p&gt;
&lt;p&gt;The second limitation of f-strings is that you can’t use backslash characters in embedded expressions. Consider the following example, where you try to &lt;a href=&quot;https://realpython.com/python-string-concatenation/&quot;&gt;concatenate strings&lt;/a&gt; using the newline (&lt;code&gt;\n&lt;/code&gt;) escape sequence:&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;words&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;I&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;am&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Pythonista!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;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;s1&quot;&gt;&#x27;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&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;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;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;s1&quot;&gt;&#x27;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&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;w&quot;&gt;                         &lt;/span&gt;&lt;span class=&quot;pm&quot;&gt;^&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;SyntaxError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;f-string expression part cannot include a backslash&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/python312-f-strings/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python312-f-strings/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Socket Programming in Python Part 1: Handling Connections</title>
      <id>https://realpython.com/courses/python-sockets-part-1/</id>
      <link href="https://realpython.com/courses/python-sockets-part-1/"/>
      <updated>2023-07-25T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to build a socket server and client with Python. Along the way, you&#x27;ll get to know the main functions and methods in Python&#x27;s socket module, and you&#x27;ll implement a multi-connection server and client.</summary>
      <content type="html">
        &lt;p&gt;Sockets and the socket API are used to send messages across a network. They provide a form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Inter-process_communication&quot;&gt;inter-process communication (IPC)&lt;/a&gt;. The network can be a logical, local network to the computer, or one that&amp;rsquo;s physically connected to an external network, with its own connections to other networks. The obvious example is the Internet, which you connect to with your ISP.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this two-part series, you&amp;rsquo;ll create:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A simple &lt;strong&gt;socket server and client&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;An improved version that handles &lt;strong&gt;multiple connections&lt;/strong&gt; simultaneously&lt;/li&gt;
&lt;li&gt;A server-client application that functions like a full-fledged &lt;strong&gt;socket application&lt;/strong&gt;, complete with its own &lt;strong&gt;custom header and content&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of part one, you&amp;rsquo;ll understand how to use the main functions and methods in Python&amp;rsquo;s &lt;a href=&quot;https://docs.python.org/3/library/socket.html&quot;&gt;socket module&lt;/a&gt; to write your own client-server applications, including ones with multiple connections. In part two, you&amp;rsquo;ll dive into building a custom class and handling errors.&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 &amp; APIs: A Winning Combo for Reading Public Data</title>
      <id>https://realpython.com/python-api/</id>
      <link href="https://realpython.com/python-api/"/>
      <updated>2023-07-24T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn what APIs are and how to consume them using Python. You&#x27;ll also learn some core concepts for working with APIs, such as status codes, HTTP methods, the requests library, and much more. You&#x27;ll also see a few examples of real-life APIs and how to consume them.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Knowing how to consume an API is one of those magical skills that, once mastered, will crack open a whole new world of possibilities, and consuming APIs using Python is a great way to learn such a skill.&lt;/p&gt;
&lt;p&gt;A lot of apps and systems that you use on a daily basis are connected to an API. From very simple and mundane tasks, like checking the weather in the morning, to more addictive and time-consuming actions, such as scrolling through your Instagram, TikTok, or Twitter feed, APIs play a central role.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What an &lt;strong&gt;API&lt;/strong&gt; is&lt;/li&gt;
&lt;li&gt;How you can &lt;strong&gt;consume APIs&lt;/strong&gt; with your Python code&lt;/li&gt;
&lt;li&gt;What the most important &lt;strong&gt;API-related concepts&lt;/strong&gt; are &lt;/li&gt;
&lt;li&gt;How Python can help you &lt;strong&gt;read data&lt;/strong&gt; that’s available through public APIs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of this tutorial, you’ll be able to use Python to consume most of the APIs that you come across. If you’re a developer, then knowing how to consume APIs with Python will make you much more proficient, especially when it comes to integrating your work with third-party applications.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In this tutorial, you’ll focus on how to &lt;em&gt;consume&lt;/em&gt; APIs using Python, not how to build them. For information on building an API with Python, check out &lt;a href=&quot;https://realpython.com/flask-connexion-rest-api/&quot;&gt;Python REST APIs With Flask, Connexion, and SQLAlchemy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You can download the source code for the examples that you’ll see in this tutorial by clicking the link below:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get the Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/consuming-apis-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-consuming-apis-python-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get the source code you’ll use&lt;/a&gt; to learn about consuming APIs with Python in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-to-know-apis&quot;&gt;Getting to Know APIs&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-apis&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;API stands for &lt;strong&gt;application programming interface&lt;/strong&gt;. In essence, an API acts as a communication layer, or interface, that allows different systems to talk to each other without having to understand exactly what the others do.&lt;/p&gt;
&lt;p&gt;APIs can come in many forms or shapes. They can be operating system APIs, used for actions like turning on your camera and audio when joining a Zoom call. Or they can be web APIs, used for web-focused actions, such as liking images on your Instagram or fetching the latest tweets.&lt;/p&gt;
&lt;p&gt;No matter the type, all APIs function mostly the same way. You usually make a &lt;strong&gt;request&lt;/strong&gt; for information or data, and the API returns a &lt;strong&gt;response&lt;/strong&gt; with what you requested. For example, every time you open Twitter or scroll down your Instagram feed, you’re basically making a request to the API behind that app and getting a response in return. This is also known as &lt;strong&gt;calling&lt;/strong&gt; an API.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll focus more on the high-level APIs that communicate across networks, also called &lt;strong&gt;web APIs&lt;/strong&gt;. &lt;/p&gt;
&lt;h3 id=&quot;soap-vs-rest-vs-graphql&quot;&gt;SOAP vs REST vs GraphQL&lt;a class=&quot;headerlink&quot; href=&quot;#soap-vs-rest-vs-graphql&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Even though some of the examples above are geared toward newer platforms or apps, web APIs have been around for quite a long time. In the late 1990s and early 2000s, two different design models became the norm in exposing data publicly:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;SOAP (Simple Object Access Protocol)&lt;/strong&gt; is typically associated with the enterprise world, has a stricter contract-based usage, and is mostly designed around actions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;REST (Representational State Transfer)&lt;/strong&gt; is typically used for public APIs and is ideal for fetching data from the Web. It’s much lighter and closer to the HTTP specification than SOAP.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Nowadays, there’s a new kid in town: &lt;a href=&quot;https://graphql.org/&quot;&gt;GraphQL&lt;/a&gt;. Created by Facebook, GraphQL is a very flexible query language for APIs, where the clients decide exactly what they want to fetch from the server instead of letting the server decide what to send.&lt;/p&gt;
&lt;p&gt;If you want to learn more about the differences between these three design models, then here are a few good resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.altexsoft.com/blog/engineering/what-is-soap-formats-protocols-message-structure-and-how-soap-is-different-from-rest/&quot;&gt;What is SOAP?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://restfulapi.net/&quot;&gt;What is REST?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://blog.postman.com/soap-vs-rest/&quot;&gt;API 101: SOAP vs. REST&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://graphql.org/learn/&quot;&gt;Introduction to GraphQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.altexsoft.com/blog/soap-vs-rest-vs-graphql-vs-rpc/&quot;&gt;Comparing API Architectural Styles: SOAP vs REST vs GraphQL vs RPC&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Even though GraphQL is on the rise and is being adopted by bigger and bigger companies, including &lt;a href=&quot;https://docs.github.com/en/graphql&quot;&gt;GitHub&lt;/a&gt; and &lt;a href=&quot;https://shopify.dev/docs/admin-api/graphql/reference&quot;&gt;Shopify&lt;/a&gt;, the truth is that the majority of public APIs are still REST APIs. Therefore, for the purpose of this tutorial, you’ll learn only about REST APIs and how to consume them using Python.&lt;/p&gt;
&lt;h3 id=&quot;apis-and-requests-a-match-made-in-heaven&quot;&gt;APIs and &lt;code&gt;requests&lt;/code&gt;: A Match Made in Heaven&lt;a class=&quot;headerlink&quot; href=&quot;#apis-and-requests-a-match-made-in-heaven&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When consuming APIs with Python, there’s only one library you need: &lt;a href=&quot;https://realpython.com/python-requests/&quot;&gt;&lt;code&gt;requests&lt;/code&gt;&lt;/a&gt;. With it, you should be able to do most, if not all, of the actions required to consume any public API.&lt;/p&gt;
&lt;p&gt;You can install &lt;code&gt;requests&lt;/code&gt; by running the following command in your console:&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&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;requests
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The examples in this tutorial have been tested with Python 3.11.2 and &lt;code&gt;requests&lt;/code&gt; 2.31.0. However, any supported version of Python and &lt;code&gt;requests&lt;/code&gt; should yield similar results.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-api/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-api/ »&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 #165: Leveraging the Features of Your Database With Postgres and Python</title>
      <id>https://realpython.com/podcasts/rpp/165/</id>
      <link href="https://realpython.com/podcasts/rpp/165/"/>
      <updated>2023-07-21T12:00:00+00:00</updated>
      <summary>Are you getting the most out of your Postgres database? What features could you leverage to improve your Python project? This week on the show, Craig Kerstiens from Crunchy Data is here to discuss getting the most out of Postgres.</summary>
      <content type="html">
        &lt;p&gt;Are you getting the most out of your Postgres database? What features could you leverage to improve your Python project? This week on the show, Craig Kerstiens from Crunchy Data is here to discuss getting the most out of Postgres.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s list Data Type: A Deep Dive With Examples</title>
      <id>https://realpython.com/python-list/</id>
      <link href="https://realpython.com/python-list/"/>
      <updated>2023-07-19T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll dive deep into Python&#x27;s lists. You&#x27;ll learn how to create them, update their content, populate and grow them, and more. Along the way, you&#x27;ll code practical examples that will help you strengthen your skills with this fundamental data type in Python.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The &lt;strong&gt;&lt;code&gt;list&lt;/code&gt;&lt;/strong&gt; class is a fundamental &lt;strong&gt;built-in data type&lt;/strong&gt; in Python. It has an impressive and useful set of features, allowing you to efficiently organize and manipulate heterogeneous data. Knowing how to use lists is a must-have skill for you as a Python developer. Lists have many use cases, so you’ll frequently reach for them in real-world coding.&lt;/p&gt;
&lt;p&gt;By working through this tutorial, you’ll dive deep into lists and get a solid understanding of their key features. This knowledge will allow you to write more effective code by taking advantage of lists.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Create&lt;/strong&gt; new lists in Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access&lt;/strong&gt; the items in an existing list&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Copy&lt;/strong&gt;, &lt;strong&gt;update&lt;/strong&gt;, &lt;strong&gt;grow&lt;/strong&gt;, &lt;strong&gt;shrink&lt;/strong&gt;, and &lt;strong&gt;concatenate&lt;/strong&gt; existing lists&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sort&lt;/strong&gt;, &lt;strong&gt;reverse&lt;/strong&gt;, and &lt;strong&gt;traverse&lt;/strong&gt; existing lists&lt;/li&gt;
&lt;li&gt;Use other &lt;strong&gt;features&lt;/strong&gt; of Python lists&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, you’ll code some examples that showcase common use cases of lists in Python. They’ll help you understand how to better use lists in your code.&lt;/p&gt;
&lt;p&gt;To get the most out of this tutorial, you should have a good understanding of core Python concepts, including &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt;. You’ll also benefit from familiarity with other built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data types&lt;/a&gt;, such as &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-namedtuple/&quot;&gt;tuples&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;sets&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-list-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-list-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the sample code&lt;/a&gt; that will make you an expert on Python’s &lt;code&gt;list&lt;/code&gt; data type.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-started-with-pythons-list-data-type&quot;&gt;Getting Started With Python’s &lt;code&gt;list&lt;/code&gt; Data Type&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-pythons-list-data-type&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s &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; is a flexible, versatile, powerful, and popular built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data type&lt;/a&gt;. It allows you to create variable-length and mutable &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-sequence&quot;&gt;sequences&lt;/a&gt; of objects. In a &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-list&quot;&gt;list&lt;/a&gt;, you can store objects of any type. You can also mix objects of different types within the same list, although list elements often share the same type.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Throughout this tutorial, you’ll use the terms &lt;strong&gt;items&lt;/strong&gt;, &lt;strong&gt;elements&lt;/strong&gt;, and &lt;strong&gt;values&lt;/strong&gt; interchangeably to refer to the objects stored in a list.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Some of the more relevant characteristics of &lt;a href=&quot;https://realpython.com/python-lists-tuples/#python-lists&quot;&gt;&lt;code&gt;list&lt;/code&gt;&lt;/a&gt; objects include being:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ordered&lt;/strong&gt;: They contain elements or items that are sequentially arranged according to their specific insertion order.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero-based&lt;/strong&gt;: They allow you to access their elements by indices that start from zero.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mutable&lt;/strong&gt;: They support in-place mutations or changes to their contained elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Heterogeneous&lt;/strong&gt;: They can store objects of different types.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Growable and dynamic&lt;/strong&gt;: They can grow or shrink dynamically, which means that they support the addition, insertion, and removal of elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nestable&lt;/strong&gt;: They can contain other lists, so you can have lists of lists.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Iterable&lt;/strong&gt;: They support iteration, so you can traverse them using a loop or comprehension while you perform operations on each of their elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sliceable&lt;/strong&gt;: They support slicing operations, meaning that you can extract a series of elements from them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combinable&lt;/strong&gt;: They support concatenation operations, so you can combine two or more lists using the concatenation operators.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Copyable&lt;/strong&gt;: They allow you to make copies of their content using various techniques.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lists are sequences of objects. They’re commonly called &lt;strong&gt;containers&lt;/strong&gt; or &lt;strong&gt;collections&lt;/strong&gt; because a single list can contain or collect an arbitrary number of other objects.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In Python, lists support a rich set of operations that are common to all sequence types, including &lt;a href=&quot;https://realpython.com/python-lists-tuples/#python-tuples&quot;&gt;tuples&lt;/a&gt;, strings, and &lt;a href=&quot;https://realpython.com/python-range/&quot;&gt;ranges&lt;/a&gt;. These operations are known as &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#common-sequence-operations&quot;&gt;common sequence operations&lt;/a&gt;. Throughout this tutorial, you’ll learn about several operations that fall into this category.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In Python, lists are ordered, which means that they keep their elements in the order of insertion:&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;colors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;red&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;s2&quot;&gt;&quot;orange&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;s2&quot;&gt;&quot;yellow&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;s2&quot;&gt;&quot;green&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;s2&quot;&gt;&quot;blue&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;s2&quot;&gt;&quot;indigo&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;s2&quot;&gt;&quot;violet&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colors&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&#x27;red&#x27;, &#x27;orange&#x27;, &#x27;yellow&#x27;, &#x27;green&#x27;, &#x27;blue&#x27;, &#x27;indigo&#x27;, &#x27;violet&#x27;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The items in this list are strings representing colors. If you access the list object, then you’ll see that the colors keep the same order in which you inserted them into the list. This order remains unchanged during the list’s lifetime unless you perform some mutations on it.&lt;/p&gt;
&lt;p&gt;You can access an individual object in a list by its position or index in the sequence. Indices start from zero:&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;colors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;red&#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;colors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;orange&#x27;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;yellow&#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;colors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;green&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Positions are numbered from zero to the length of the list minus one. The element at index &lt;code&gt;0&lt;/code&gt; is the first element in the list, the element at index &lt;code&gt;1&lt;/code&gt; is the second, and so on.&lt;/p&gt;
&lt;p&gt;Lists can contain objects of different types. That’s why lists are heterogeneous collections:&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;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;apple&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;John Doe&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.78&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;This list contains objects of different data types, including an integer &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt;, string, &lt;a href=&quot;https://realpython.com/python-boolean/&quot;&gt;Boolean&lt;/a&gt; value, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt;, tuple, and another list. Even though this feature of lists may seem cool, in practice you’ll find that lists typically store homogeneous data.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; One of the most relevant characteristics of lists is that they’re &lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/#lists&quot;&gt;mutable&lt;/a&gt; data types. This feature deeply impacts their behavior and use cases. For example, mutability implies that lists aren’t &lt;a href=&quot;https://realpython.com/python-hash-table/&quot;&gt;hashable&lt;/a&gt;, so you can’t use them as dictionary &lt;a href=&quot;https://realpython.com/python-dicts/#dictionary-keys-vs-list-indices&quot;&gt;keys&lt;/a&gt;. You’ll learn a lot about how mutability affects lists throughout this tutorial. So, keep reading!&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Okay! That’s enough for a first glance at Python lists. In the rest of this tutorial, you’ll dive deeper into all the above characteristics of lists and more. Are you ready? To kick things off, you’ll start by learning the different ways to create lists.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-list/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/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>Creating Web Maps From Your Data With Python Folium</title>
      <id>https://realpython.com/courses/python-folium-web-maps-from-data/</id>
      <link href="https://realpython.com/courses/python-folium-web-maps-from-data/"/>
      <updated>2023-07-18T14:00:00+00:00</updated>
      <summary>You&#x27;ll learn how to create web maps from data using Folium. The package combines Python&#x27;s data-wrangling strengths with the data-visualization power of the JavaScript library Leaflet. In this video course, you&#x27;ll create and style a choropleth world map showing the ecological footprint per country.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re working with geospatial data in Python, then you might want to quickly visualize that data on a map. Python&amp;rsquo;s Folium library gives you access to the mapping strengths of the &lt;a href=&quot;https://leafletjs.com/&quot;&gt;Leaflet&lt;/a&gt; JavaScript library through a Python API. It allows you to create interactive geographic visualizations that you can &lt;a href=&quot;https://realpython.github.io/ecological-footprint/&quot;&gt;share as a website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll build a web map that displays the &lt;a href=&quot;https://en.wikipedia.org/wiki/Ecological_footprint&quot;&gt;ecological footprint&lt;/a&gt; per capita of many countries and is based on a &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_countries_by_ecological_footprint#/media/File:Ecological_footprint_2018.png&quot;&gt;similar map on Wikipedia&lt;/a&gt;. Along the way, you&amp;rsquo;ll learn the basics of using Folium for data visualization.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create an &lt;strong&gt;interactive map&lt;/strong&gt; using Folium and save it as an &lt;strong&gt;HTML&lt;/strong&gt; file&lt;/li&gt;
&lt;li&gt;Choose from different &lt;strong&gt;web map tiles&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Anchor your map to a &lt;strong&gt;specific geolocation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bind data&lt;/strong&gt; to a &lt;strong&gt;GeoJSON&lt;/strong&gt; layer to create a &lt;strong&gt;choropleth map&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Style&lt;/strong&gt; the choropleth map&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;rsquo;ll use Folium inside of a &lt;a href=&quot;https://realpython.com/jupyter-notebook-introduction/&quot;&gt;Jupyter notebook&lt;/a&gt;, so the Folium library will render your maps directly in the Jupyter notebook. This gives you a good opportunity to visually explore a geographical dataset or include a map in your data science report.&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 June 2023</title>
      <id>https://realpython.com/python-news-june-2023/</id>
      <link href="https://realpython.com/python-news-june-2023/"/>
      <updated>2023-07-17T14:00:00+00:00</updated>
      <summary>In June 2023, the PSF held a board of directors election and welcomed a new security developer in residence. They also announced a CPython deputy developer in residence role. Pydantic released a new version, while Python 3.7 reached its end of life.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;June 2023 welcomed a lot of new people and positions to the &lt;strong&gt;Python Software Foundation (PSF)&lt;/strong&gt;. Elections wrapped up for &lt;strong&gt;directors&lt;/strong&gt;, and a new &lt;strong&gt;security developer in residence&lt;/strong&gt; got to work. The organization is still looking to expand, though, and it announced a new &lt;strong&gt;deputy CPython developer in residence&lt;/strong&gt; position that could go to a less seasoned programmer. Over at &lt;strong&gt;Pydantic&lt;/strong&gt;, version 2 brings improved performance, while the sun went down on &lt;strong&gt;Python 3.7&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It’s summer, so get ready for some hot Python news!&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;psf-elects-new-directors&quot;&gt;PSF Elects New Directors&lt;a class=&quot;headerlink&quot; href=&quot;#psf-elects-new-directors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.python.org/psf-landing/&quot;&gt;Python Software Foundation (PSF)&lt;/a&gt; is the nonprofit organization behind Python. If you’re wondering what exactly the PSF does, the answer is &lt;em&gt;a bunch&lt;/em&gt;! Here’s a bird’s-eye view of their role in the language and community:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to support and facilitate the growth of a diverse and international community of Python programmers. (&lt;a href=&quot;https://www.python.org/psf/mission/&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Elections to fill four seats on the PSF &lt;strong&gt;board of directors&lt;/strong&gt; occurred during the second half of June. A term for a seat on the PSF board of directors lasts three years, and directors are eligible for reelection. To vote in this election, you had to be a registered &lt;a href=&quot;https://www.python.org/psf/membership/&quot;&gt;PSF member&lt;/a&gt; with voting rights.&lt;/p&gt;
&lt;p&gt;This year, there were a lot of &lt;a href=&quot;https://www.python.org/nominations/elections/2023-python-software-foundation-board/nominees/&quot;&gt;nominees&lt;/a&gt;. In this crowded race, four people &lt;a href=&quot;https://pyfound.blogspot.com/2023/06/announcing-2023-psf-board-election.html&quot;&gt;received the most votes&lt;/a&gt; and were elected to fill the seats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.python.org/nominations/elections/2023-python-software-foundation-board/nominees/cheuk-ting-ho/&quot;&gt;Cheuk Ting Ho&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.python.org/nominations/elections/2023-python-software-foundation-board/nominees/denny-perez/&quot;&gt;Denny Perez&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.python.org/nominations/elections/2023-python-software-foundation-board/nominees/georgi-ker/&quot;&gt;Georgi Ker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.python.org/nominations/elections/2023-python-software-foundation-board/nominees/christopher-neugebauer/&quot;&gt;Christopher Neugebauer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you’re curious about what it means to serve on the PSF board and what a &lt;a href=&quot;https://wiki.python.org/moin/PythonSoftwareFoundation/DutiesAndResponsibilitiesOfDirectors&quot;&gt;director’s duties&lt;/a&gt; are, then you can watch a video in which three board members describe &lt;a href=&quot;https://www.youtube.com/watch?v=ZLKj6FaQA4M&quot;&gt;Life as a Python Software Foundation Director&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Congratulations to the new and returning board directors, and big thanks to all the other nominees for their continued engagement in the Python community. Community service is what keeps Python thriving.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-june-2023/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-june-2023/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #164: Constructing Python Library APIs &amp; Tackling Jinja Templating</title>
      <id>https://realpython.com/podcasts/rpp/164/</id>
      <link href="https://realpython.com/podcasts/rpp/164/"/>
      <updated>2023-07-14T12:00:00+00:00</updated>
      <summary>What principles should you consider when designing a Python library? How do you construct a library API that&#x27;s understandable and easy to use? 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;What principles should you consider when designing a Python library? How do you construct a library API that&#x27;s understandable and easy to use? 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>Unlock IPython&#x27;s Magical Toolbox for Your Coding Journey</title>
      <id>https://realpython.com/ipython-interactive-python-shell/</id>
      <link href="https://realpython.com/ipython-interactive-python-shell/"/>
      <updated>2023-07-12T14:00:00+00:00</updated>
      <summary>IPython is a powerful tool that can prove useful on your journey to mastering Python. Its friendly interface will enable you to comfortably take control of your learning. In this tutorial, you&#x27;ll cover the basic concepts of using IPython and learn how its features can make coding efficient.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you’re executing Python code, the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;standard Python shell&lt;/a&gt; that comes with your Python installation is a natural tool to use. However, as you progress in your coding journey, you might find yourself seeking more powerful functionalities than the standard REPL offers. Luckily, &lt;strong&gt;IPython&lt;/strong&gt; offers an enhanced version of &lt;strong&gt;interactive Python&lt;/strong&gt; that can supercharge your capabilities.&lt;/p&gt;
&lt;p&gt;Using the IPython shell is a fast way of learning Python and executing code without the need for a full-fledged &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;integrated development environment (IDE)&lt;/a&gt;, such as &lt;a href=&quot;https://realpython.com/pycharm-guide/&quot;&gt;PyCharm&lt;/a&gt;. IPython adds great features to the Python experience with its &lt;strong&gt;magic commands&lt;/strong&gt;, which the standard Python shell lacks. These can help you complete tasks more quickly. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn the major aspects and &lt;strong&gt;functionality&lt;/strong&gt; of the IPython shell&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write&lt;/strong&gt; and &lt;strong&gt;execute code&lt;/strong&gt; in IPython&lt;/li&gt;
&lt;li&gt;Integrate IPython in your &lt;strong&gt;Python scripts&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use IPython’s &lt;strong&gt;magic commands&lt;/strong&gt; in your coding sessions&lt;/li&gt;
&lt;li&gt;Learn how to &lt;strong&gt;save your sessions&lt;/strong&gt; persistently in a Python file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get started with IPython, you don’t need to be far along in your Python journey. In fact, IPython is an excellent learning tool because it offers an &lt;strong&gt;intuitive interface&lt;/strong&gt;. Are you ready to get started?&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/ipython-interactive-python-shell-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-ipython-interactive-python-shell-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download code resources and a cheat sheet&lt;/a&gt; so you can work magic with IPython.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;install-and-initiate-ipython-on-your-machine&quot;&gt;Install and Initiate IPython on Your Machine&lt;a class=&quot;headerlink&quot; href=&quot;#install-and-initiate-ipython-on-your-machine&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It only takes a few steps to install and initiate IPython. First, you’ll need to &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;install Python&lt;/a&gt; on your system. You also might want to create and activate a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt; instead of installing IPython into your global Python.&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; IPython comes installed with the &lt;a href=&quot;https://realpython.com/python-windows-machine-learning-setup/#introducing-anaconda-and-conda&quot;&gt;Anaconda package&lt;/a&gt;. If you’ve installed the full Anaconda package, then you already have IPython.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To install IPython, use &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt; on the command line: &lt;/p&gt;
&lt;div class=&quot;highlight doscon&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;C:\Users\User&amp;gt;&lt;/span&gt;python -m pip install ipython
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just like that, you should see a message that the installation was successful. That means the package has installed all the dependencies, and you should be able to begin using the interactive shell. If you encounter any issues, please consult the &lt;a href=&quot;https://ipython.readthedocs.io/en/stable/install/install.html&quot;&gt;documentation&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;After the installation process is finished, you can initiate the &lt;strong&gt;interactive shell&lt;/strong&gt; by executing the command &lt;code&gt;ipython&lt;/code&gt; on the command line: &lt;/p&gt;
&lt;div class=&quot;highlight doscon&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;C:\Users\User&amp;gt;&lt;/span&gt;ipython
&lt;span class=&quot;go&quot;&gt;Python 3.11.4 (main, Jun 27 2023, 11:06:35) [Clang 14.0.0 (clang-1400.0.29.202)]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &#x27;copyright&#x27;, &#x27;credits&#x27; or &#x27;license&#x27; for more information&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;IPython 8.14.0 -- An enhanced Interactive Python. Type &#x27;?&#x27; for help.&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;In [1]:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You’ll see the above message at the start of the session, confirming the successful installation of IPython on your machine. The shell initiates the first &lt;a href=&quot;#understanding-the-input-and-output-prompts&quot;&gt;prompt&lt;/a&gt;, with &lt;code&gt;In [1]&lt;/code&gt; indicating that it’s ready to accept input.&lt;/p&gt;
&lt;p&gt;To exit the interactive shell, you can use the &lt;code&gt;exit&lt;/code&gt; command, and you’ll switch from IPython to the command line. Now that you have IPython up and running, you’re ready to explore how it can transform your Python workflow. That’s what you’ll discover next.&lt;/p&gt;
&lt;h2 id=&quot;improve-your-interactive-python-workflow-with-ipython&quot;&gt;Improve Your Interactive Python Workflow With IPython&lt;a class=&quot;headerlink&quot; href=&quot;#improve-your-interactive-python-workflow-with-ipython&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Python standard shell is a fantastic and versatile tool. However, IPython takes things up a notch by incorporating powerful features that can greatly enhance your coding productivity. While you can explore all of its strengths in the &lt;a href=&quot;https://IPython.readthedocs.io/en/stable/&quot;&gt;documentation&lt;/a&gt;, here are a few noteworthy distinctions that add up to a more user-friendly interface:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;#understanding-the-input-and-output-prompts&quot;&gt;Numbered prompts&lt;/a&gt; can give you a stronger understanding of the input code and output results. &lt;/li&gt;
&lt;li&gt;IPython has so many &lt;a href=&quot;#become-a-power-user-with-ipython-magic-commands&quot;&gt;magic commands&lt;/a&gt; that the standard Python shell lacks, and they make working in the shell efficient.&lt;/li&gt;
&lt;li&gt;You can access your &lt;a href=&quot;#scanning-code-history&quot;&gt;code history&lt;/a&gt; within the shell.&lt;/li&gt;
&lt;li&gt;It makes object &lt;a href=&quot;#understanding-objects-through-introspection&quot;&gt;introspection&lt;/a&gt; and code documentation accessible.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These advantages can make a huge difference in your life as a programmer. You’ll get to know these productivity boosters in the coming sections.&lt;/p&gt;
&lt;p&gt;IPython is also available through &lt;a href=&quot;https://realpython.com/jupyter-notebook-introduction/&quot;&gt;Jupyter Notebooks&lt;/a&gt;. This browser-based interactive interface offers similar features, such as magic commands and numbered input and output. Its &lt;a href=&quot;https://ipython.readthedocs.io/en/stable/overview.html#decoupled-two-process-model&quot;&gt;decoupled two-process model&lt;/a&gt; separates the front-end and back-end components of IPython into distinct processes. This allows the IPython kernel to function independently and handle code execution, namespace management, and communication between the shell and kernel.&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; IPython isn’t the only interactive shell that you can use. In the Python-verse, options abound, and you can choose your favorite shell out of &lt;a href=&quot;https://realpython.com/bpython-alternative-python-repl/&quot;&gt;bpython&lt;/a&gt;, &lt;a href=&quot;https://github.com/prompt-toolkit/ptpython&quot;&gt;ptpython&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt;, and others.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The standard Python shell allows you to interact with Python on the command line. It permits you to enter statements or expressions one at a time. Then, it executes them and displays the corresponding output:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 &quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/839640061?background=1&quot; frameborder=&quot;0&quot; allow=&quot;fullscreen&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;In the above code examples, you’re able to define two &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt;, &lt;code&gt;first_name&lt;/code&gt; and &lt;code&gt;last_name&lt;/code&gt;, and then &lt;a href=&quot;https://realpython.com/python-string-concatenation/&quot;&gt;concatenate&lt;/a&gt; the two strings. You can create mini-programs in the Python shell by creating other objects, such as &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;class objects&lt;/a&gt;.  &lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/ipython-interactive-python-shell/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ipython-interactive-python-shell/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Mazes in Python Part 2: Storing and Solving</title>
      <id>https://realpython.com/courses/python-maze-solver-part-2/</id>
      <link href="https://realpython.com/courses/python-maze-solver-part-2/"/>
      <updated>2023-07-11T14:00:00+00:00</updated>
      <summary>In part two of this two-part project, you&#x27;ll define a specialized binary file format to store a maze on disk, transform the maze into a traversable weighted graph, and use a graph search algorithm in the NetworkX library to find the solution.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re up for a little challenge and would like to take your programming skills to the next level, then you&amp;rsquo;ve come to the right place! In this hands-on video course, you&amp;rsquo;ll practice object-oriented programming, among several other good practices, while building a cool maze solver project in Python.&lt;/p&gt;
&lt;p&gt;This is the second part in a two-part series. Throughout the series, you&amp;rsquo;re going step by step through the guided process of building a complete and working project. This includes reading a maze from a binary file, visualizing it using scalable vector graphics (SVG), and finding the shortest path from the entrance to the exit. &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;Define a specialized &lt;strong&gt;binary file format&lt;/strong&gt; to store the maze on disk&lt;/li&gt;
&lt;li&gt;Transform the maze into a traversable &lt;strong&gt;weighted graph&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use a &lt;strong&gt;graph search algorithm&lt;/strong&gt; in the NetworkX library to find the solution.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this video course, make sure you&amp;rsquo;ve completed &lt;a href=&quot;https://realpython.com/courses/python-maze-solver-part-1/&quot;&gt;Part 1: Building and Visualizing&lt;/a&gt;.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Profiling in Python: How to Find Performance Bottlenecks</title>
      <id>https://realpython.com/python-profiling/</id>
      <link href="https://realpython.com/python-profiling/"/>
      <updated>2023-07-10T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to profile your Python programs using numerous tools available in the standard library, third-party libraries, as well as a powerful tool foreign to Python. Along the way, you&#x27;ll learn what profiling is and cover a few related concepts.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Do you want to optimize the performance of your Python program to make it run faster or consume less memory? Before diving into any performance tuning, you should strongly consider using a technique called &lt;strong&gt;software profiling&lt;/strong&gt;. It may help you answer whether optimizing the code is necessary and, if so, which parts of the code you should focus on.&lt;/p&gt;
&lt;p&gt;Sometimes, the return on investment in performance optimizations just isn’t worth the effort. If you only run your code once or twice, or if it takes longer to improve the code than execute it, then what’s the point?&lt;/p&gt;
&lt;p&gt;When it comes to improving the quality of your code, you’ll probably optimize for performance as a final step, if you do it at all. Often, your code will become speedier and more memory efficient thanks to other changes that you make. When in doubt, go through this short checklist to figure out whether to work on performance:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/tutorials/testing/&quot;&gt;Testing&lt;/a&gt;: Have you tested your code to prove that it works as expected and without errors?&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-refactoring/&quot;&gt;Refactoring&lt;/a&gt;: Does your code need some cleanup to become more maintainable and &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;Pythonic&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-timer/#finding-bottlenecks-in-your-code-with-profilers&quot;&gt;Profiling&lt;/a&gt;: Have you identified the most inefficient parts of your code?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Only when all the above items check out should you consider optimizing for performance. It’s usually more important that your code runs correctly according to the business requirements and that other team members can understand it than that it’s the most efficient solution.&lt;/p&gt;
&lt;p&gt;The actual time-saver might be elsewhere. For example, having the ability to quickly extend your code with new features before your competitors will make a real impact. That’s especially true when the performance bottleneck lies not in the underlying code’s execution time but in network communication. Making Python run faster won’t win you anything in that case, but it’ll likely increase the code’s complexity.&lt;/p&gt;
&lt;p&gt;Finally, your code will often become faster as a result of fixing the bugs and refactoring. One of the creators of &lt;a href=&quot;https://en.wikipedia.org/wiki/Erlang_(programming_language)&quot;&gt;Erlang&lt;/a&gt; once said:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Make it work, then make it beautiful, then if you really, really have to, make it fast. 90 percent of the time, if you make it beautiful, it will already be fast. So really, just make it beautiful! (&lt;a href=&quot;https://henrikwarne.com/2021/04/16/more-good-programming-quotes-part-5/&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;— &lt;em&gt;Joe Armstrong&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As a rule of thumb, anytime you’re considering optimization, you should profile your code first to identify which bottlenecks to address. Otherwise, you may find yourself chasing the wrong rabbit. Because of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Pareto_principle&quot;&gt;Pareto principle&lt;/a&gt; or the 80/20 rule, which applies to a surprisingly wide range of areas in life, optimizing just 20 percent of your code will often yield 80 percent of the benefits!&lt;/p&gt;
&lt;p&gt;But without having factual data from a profiler tool, you won’t know for sure which parts of the code are worth improving. It’s too easy to make false assumptions.&lt;/p&gt;
&lt;p&gt;So, what’s software profiling, and how do you profile programs written 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 Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-profiling-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-profiling-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here download your sample code&lt;/a&gt; for profiling your Python program to find performance bottlenecks.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-find-performance-bottlenecks-in-your-python-code-through-profiling&quot;&gt;How to Find Performance Bottlenecks in Your Python Code Through Profiling&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-find-performance-bottlenecks-in-your-python-code-through-profiling&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Profiling_(computer_programming)&quot;&gt;Software profiling&lt;/a&gt; is the process of collecting and analyzing various metrics of a running program to identify performance bottlenecks known as &lt;strong&gt;hot spots&lt;/strong&gt;. These hot spots can happen due to a number of reasons, including excessive memory use, inefficient CPU utilization, or a suboptimal data layout, which will result in frequent &lt;a href=&quot;https://en.wikipedia.org/wiki/CPU_cache#Cache_miss&quot;&gt;cache misses&lt;/a&gt; that increase &lt;a href=&quot;https://en.wikipedia.org/wiki/Latency_(engineering)&quot;&gt;latency&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; A performance profiler is a valuable tool for identifying hot spots in existing code, but it won’t tell you how to write efficient code from the start.&lt;/p&gt;
&lt;p&gt;It’s often the choice of the underlying &lt;a href=&quot;https://en.wikipedia.org/wiki/Algorithm&quot;&gt;algorithm&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-data-structures/&quot;&gt;data structure&lt;/a&gt; that can make the biggest difference. Even when you throw the most advanced hardware available on the market at some computational problem, an algorithm with a poor &lt;a href=&quot;https://en.wikipedia.org/wiki/Time_complexity&quot;&gt;time&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Space_complexity&quot;&gt;space complexity&lt;/a&gt; may never finish in a reasonable time.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;When profiling, it’s important that you perform &lt;strong&gt;dynamic analysis&lt;/strong&gt; by executing your code and collecting real-world data rather than relying on static code review. Because dynamic analysis often entails running a slow piece of software over and over again, you should start by feeding small amounts of input data to your algorithm if possible. This will limit the amount of time that you spend waiting for results on each iteration.&lt;/p&gt;
&lt;p&gt;Once you have your code running, you can use one of the many Python profilers available. There are many kinds of profilers out there, which can make your head spin. Ultimately, you should know how to pick the right tool for the job. Over the next few sections, you’ll get a quick tour of the most popular Python profiling tools and concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Timers&lt;/strong&gt; like the &lt;code&gt;time&lt;/code&gt; and &lt;code&gt;timeit&lt;/code&gt; standard library modules, or the &lt;code&gt;codetiming&lt;/code&gt; third-party package&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deterministic profilers&lt;/strong&gt; like &lt;code&gt;profile&lt;/code&gt;, &lt;code&gt;cProfile&lt;/code&gt;, and line_profiler&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Statistical profilers&lt;/strong&gt; like Pyinstrument and the Linux &lt;code&gt;perf&lt;/code&gt; profiler&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fasten your seatbelt because you’re about to get a crash course in Python’s performance profiling!&lt;/p&gt;
&lt;h2 id=&quot;time-measure-the-execution-time&quot;&gt;&lt;code&gt;time&lt;/code&gt;: Measure the Execution Time&lt;a class=&quot;headerlink&quot; href=&quot;#time-measure-the-execution-time&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python, the most basic form of profiling involves measuring the code execution time by calling one of the &lt;a href=&quot;https://realpython.com/python-timer/&quot;&gt;timer functions&lt;/a&gt; from the &lt;a href=&quot;https://realpython.com/python-time-module/&quot;&gt;&lt;code&gt;time&lt;/code&gt;&lt;/a&gt; module:&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;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sleeper&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;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.75&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;spinlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&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;mi&quot;&gt;100_000_000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;pass&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sleeper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spinlock&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;t1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;perf_counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;process_time&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;function&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;t2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;perf_counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;process_time&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;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;function&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;()&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;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;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot; Real time: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&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;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t1&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;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.2f&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; seconds&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;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot; CPU time: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.2f&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; seconds&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;nb&quot;&gt;print&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;sleeper()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; Real time: 1.75 seconds&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; CPU time: 0.00 seconds&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;spinlock()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; Real time: 1.77 seconds&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; CPU time: 1.77 seconds&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You first define two test functions, &lt;code&gt;sleeper()&lt;/code&gt; and &lt;code&gt;spinlock()&lt;/code&gt;. The first function asks your operating system’s &lt;a href=&quot;https://en.wikipedia.org/wiki/Scheduling_(computing)&quot;&gt;task scheduler&lt;/a&gt; to suspend the current &lt;a href=&quot;https://realpython.com/intro-to-python-threading/&quot;&gt;thread of execution&lt;/a&gt; for about 1.75 seconds. During this time, the function remains dormant without occupying your computer’s CPU, allowing other threads or programs to run. In contrast, the second function performs a form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Busy_waiting&quot;&gt;busy waiting&lt;/a&gt; by wasting &lt;a href=&quot;https://en.wikipedia.org/wiki/Instruction_cycle&quot;&gt;CPU cycles&lt;/a&gt; without doing any useful work.&lt;/p&gt;
&lt;p&gt;Later, you call both of your test functions. Before and after each invocation, you check the current time with &lt;a href=&quot;https://docs.python.org/3/library/time.html#time.perf_counter&quot;&gt;&lt;code&gt;time.perf_counter()&lt;/code&gt;&lt;/a&gt; to obtain the &lt;a href=&quot;https://en.wikipedia.org/wiki/Elapsed_real_time&quot;&gt;elapsed real time&lt;/a&gt;, or wall-clock time, and &lt;a href=&quot;https://docs.python.org/3/library/time.html#time.process_time&quot;&gt;&lt;code&gt;time.process_time()&lt;/code&gt;&lt;/a&gt; to get the &lt;a href=&quot;https://en.wikipedia.org/wiki/CPU_time&quot;&gt;CPU time&lt;/a&gt;. These will tell you how long your functions took to execute and how much of that time they spent on the processor. If a function waits for another thread or an &lt;a href=&quot;https://en.wikipedia.org/wiki/Input/output&quot;&gt;I/O operation&lt;/a&gt; to finish, then it won’t use any CPU time.&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 performance of a computer program is typically limited by the available processing power, memory amount, input and output operations, and program latency.&lt;/p&gt;
&lt;p&gt;If a given task predominantly does a lot of computation, then the processor’s speed will determine how long it’ll take to finish. Such a task is &lt;a href=&quot;https://en.wikipedia.org/wiki/CPU-bound&quot;&gt;CPU-bound&lt;/a&gt;. You can sometimes run such tasks &lt;a href=&quot;https://realpython.com/python-concurrency/#what-is-parallelism&quot;&gt;in parallel&lt;/a&gt; on multiple CPU cores simultaneously to reduce the overall computation time.&lt;/p&gt;
&lt;p&gt;On the other hand, an &lt;a href=&quot;https://en.wikipedia.org/wiki/I/O_bound&quot;&gt;I/O-bound&lt;/a&gt; task spends most of its time waiting for data to arrive from a disk, a database, or a network. Such tasks can benefit from using faster I/O channels or running them &lt;a href=&quot;https://realpython.com/python-concurrency/&quot;&gt;concurrently&lt;/a&gt; as well as &lt;a href=&quot;https://realpython.com/async-io-python/&quot;&gt;asynchronously&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-profiling/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-profiling/ »&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 #163: Python Crash Course &amp; Learning Enough to Start Creating</title>
      <id>https://realpython.com/podcasts/rpp/163/</id>
      <link href="https://realpython.com/podcasts/rpp/163/"/>
      <updated>2023-07-07T12:00:00+00:00</updated>
      <summary>How much Python do you need to learn to start creating projects? What&#x27;s a good balance of information and hands-on practice? This week on the show, Eric Matthes is here to discuss his book Python Crash Course.</summary>
      <content type="html">
        &lt;p&gt;How much Python do you need to learn to start creating projects? What&#x27;s a good balance of information and hands-on practice? This week on the show, Eric Matthes is here to discuss his book Python Crash 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 3.12 Preview: Support For the Linux perf Profiler</title>
      <id>https://realpython.com/python312-perf-profiler/</id>
      <link href="https://realpython.com/python312-perf-profiler/"/>
      <updated>2023-07-05T14:00:00+00:00</updated>
      <summary>Python 3.12 will be released in October 2023. In this tutorial, you&#x27;ll preview one of its upcoming features: support for the Linux perf profiler, which will give you a holistic view of your application&#x27;s performance, including system-level and hardware-level events.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The final release of Python 3.12 is scheduled for October 2023, which is growing closer. In the meantime, you can download and &lt;a href=&quot;https://realpython.com/python-pre-release/&quot;&gt;install its preview version&lt;/a&gt; to get a sneak peek at the upcoming features. One of the biggest changes announced is support for the Linux &lt;code&gt;perf&lt;/code&gt; profiler, which is a powerful performance profiling tool.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install and use the &lt;strong&gt;Linux &lt;code&gt;perf&lt;/code&gt; profiler&lt;/strong&gt; with Python 3.12&lt;/li&gt;
&lt;li&gt;Get a &lt;strong&gt;holistic view&lt;/strong&gt; of your application’s performance&lt;/li&gt;
&lt;li&gt;Explore a &lt;strong&gt;case study&lt;/strong&gt; of profiling Python code with &lt;code&gt;perf&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Visualize the collected metrics with &lt;strong&gt;flame graphs&lt;/strong&gt; and more&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To fully benefit from using the &lt;code&gt;perf&lt;/code&gt; profiler in Python 3.12, you should have a fairly good understanding of how the underlying hardware and the operating system work. In addition to that, you need to be comfortable using a Linux distribution and the build tools for compiling Python from source code.&lt;/p&gt;
&lt;p&gt;There are many other new features and improvements coming in Python 3.12. The highlights include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python312-error-messages/&quot;&gt;Ever better error messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;More powerful f-strings&lt;/li&gt;
&lt;li&gt;Better support for subinterpreters&lt;/li&gt;
&lt;li&gt;Improved static typing features&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://docs.python.org/3.12/whatsnew/3.12.html&quot;&gt;what’s new&lt;/a&gt; in the changelog for more details on these 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 Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-312-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-312-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your sample code&lt;/a&gt; for a sneak peek at Python 3.12, coming in October 2023.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;seeing-the-big-picture-through-the-lens-of-perf&quot;&gt;Seeing the Big Picture Through the Lens of &lt;code&gt;perf&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#seeing-the-big-picture-through-the-lens-of-perf&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Linux &lt;code&gt;perf&lt;/code&gt; profiler is a truly versatile performance analysis tool. At the very least, you can use it as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Profiling_(computer_programming)#Statistical_profilers&quot;&gt;statistical profiler&lt;/a&gt; to find &lt;a href=&quot;https://en.wikipedia.org/wiki/Hot_spot_(computer_programming)&quot;&gt;hot spots&lt;/a&gt; in your own code, library code, and even the operating system’s code. In fact, you can hook it up to any running process, such as your web browser, and obtain its live profile, as long as you have sufficient permissions and the program was compiled with &lt;a href=&quot;https://en.wikipedia.org/wiki/Debug_symbol&quot;&gt;debug symbols&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The tool can also work as an &lt;strong&gt;event counter&lt;/strong&gt; by measuring the exact number of low-level events occurring in both hardware and software. For example, it’s capable of counting the number of &lt;a href=&quot;https://en.wikipedia.org/wiki/Instruction_cycle&quot;&gt;CPU cycles&lt;/a&gt;, instructions executed by the processor, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Context_switch&quot;&gt;context switches&lt;/a&gt; during a program’s execution. The specific types of events may vary depending on your hardware architecture and the Linux kernel version.&lt;/p&gt;
&lt;p&gt;Another useful feature of &lt;code&gt;perf&lt;/code&gt; is the ability to retain the &lt;a href=&quot;https://en.wikipedia.org/wiki/Call_graph&quot;&gt;call graph&lt;/a&gt; of functions, which can help you understand which of potentially many calls to the same function is an actual bottleneck. With a bit of effort, you can even visualize your code paths in the form of a mathematical graph consisting of nodes and edges.&lt;/p&gt;
&lt;p&gt;In this short section, you’ll get a basic understanding of the Linux &lt;code&gt;perf&lt;/code&gt; profiler and its advantages over other profiling tools. If you’re already familiar with this tool, then you can jump ahead to a &lt;a href=&quot;#getting-perf-to-work-with-python-312-on-ubuntu-linux&quot;&gt;later section&lt;/a&gt; to get your hands dirty and see it in action.&lt;/p&gt;
&lt;h3 id=&quot;whats-the-linux-perf-profiler&quot;&gt;What’s the Linux &lt;code&gt;perf&lt;/code&gt; Profiler?&lt;a class=&quot;headerlink&quot; href=&quot;#whats-the-linux-perf-profiler&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you search online for information about the Linux &lt;code&gt;perf&lt;/code&gt; profiler, then you may get confused by the plethora of names that people use to talk about it. To make matters worse, the profiler seems to be poorly documented. You really need to dig deep, as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Perf_(Linux)&quot;&gt;corresponding article on Wikipedia&lt;/a&gt; and the &lt;a href=&quot;https://perf.wiki.kernel.org/index.php/Main_Page&quot;&gt;official Wiki page&lt;/a&gt; don’t provide a lot of help.&lt;/p&gt;
&lt;p&gt;The Linux &lt;code&gt;perf&lt;/code&gt; profiler actually consists of two high-level components:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;perf_events&lt;/code&gt;, or performance counters for Linux (PCL):&lt;/strong&gt; A subsystem in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Linux_kernel&quot;&gt;Linux kernel&lt;/a&gt; with an API that provides an abstraction layer over a hardware-specific &lt;a href=&quot;https://documentation.suse.com/sles/15-SP1/html/SLES-all/cha-perf.html&quot;&gt;performance monitoring unit (PMU)&lt;/a&gt; present in modern architectures. The PMU consists of special &lt;a href=&quot;https://en.wikipedia.org/wiki/Processor_register&quot;&gt;CPU registers&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Hardware_performance_counter&quot;&gt;counters&lt;/a&gt; for collecting metrics about events such as the number of cache misses, CPU cycles, or executed instructions. This information is invaluable during performance analysis.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;perf&lt;/code&gt; command-line tool:&lt;/strong&gt; A &lt;a href=&quot;https://en.wikipedia.org/wiki/User_space_and_kernel_space&quot;&gt;user-space&lt;/a&gt; utility tool built on top of the &lt;code&gt;perf_events&lt;/code&gt; API from the Linux kernel, which can help you collect and make sense of the data. It follows the same philosophy as &lt;a href=&quot;https://realpython.com/advanced-git-for-pythonistas/&quot;&gt;Git&lt;/a&gt; by offering several specialized subcommands. You can list them all by typing &lt;code&gt;perf&lt;/code&gt; at your command prompt.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first component is baked right into the Linux kernel, meaning that recent versions of mainstream &lt;a href=&quot;https://en.wikipedia.org/wiki/Linux_distribution&quot;&gt;Linux distributions&lt;/a&gt; will usually have it shipped and enabled. On the other hand, you’ll most likely need to install an additional package to start using the &lt;code&gt;perf&lt;/code&gt; command, as it’s not essential for regular users.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Each processor and operating system combination supports a different set of event types. Therefore, you may sometimes need to reinstall &lt;code&gt;perf&lt;/code&gt; to match your current kernel version after an upgrade.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;While the Linux &lt;code&gt;perf&lt;/code&gt; profiler came into existence primarily as an interface to hardware-level performance counters, it also covers numerous software performance counters. For example, you can use it to track the number of context switches made by your operating system’s task scheduler or the number of times a running thread has migrated from one CPU core to another.&lt;/p&gt;
&lt;p&gt;Okay, but are there any other benefits of using the Linux &lt;code&gt;perf&lt;/code&gt; profiler aside from its hardware capabilities?&lt;/p&gt;
&lt;h3 id=&quot;how-can-python-benefit-from-perf&quot;&gt;How Can Python Benefit From &lt;code&gt;perf&lt;/code&gt;?&lt;a class=&quot;headerlink&quot; href=&quot;#how-can-python-benefit-from-perf&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For several reasons, adding support for the Linux &lt;code&gt;perf&lt;/code&gt; profiler will greatly impact your ability to profile Python applications. There’s no better source to refer to than &lt;a href=&quot;https://github.com/pablogsal&quot;&gt;Pablo Galindo Salgado&lt;/a&gt;, who’s the primary contributor behind this new feature. In a Twitter announcement, he thoroughly explains the benefits of the Python and &lt;code&gt;perf&lt;/code&gt; integration:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Python 3.12 will add support for the Linux perf profiler! 🔥🔥 Perf is one of the most powerful and performant profilers for Linux that allows getting a ridiculous amount of information such as CPU counters, cache misses, context switching, and much more. (&lt;a href=&quot;https://twitter.com/pyblogsal/status/1587146448503808006&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The lengthy tweet thread gives examples of several new capabilities:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python312-perf-profiler/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python312-perf-profiler/ »&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>Filtering Iterables With Python</title>
      <id>https://realpython.com/courses/python-filter-function/</id>
      <link href="https://realpython.com/courses/python-filter-function/"/>
      <updated>2023-07-04T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how Python&#x27;s filter() works and how to use it effectively in your programs. You&#x27;ll also learn how to use list comprehension and generator expressions to replace filter() and make your code more Pythonic.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;a href=&quot;https://docs.python.org/3/library/functions.html#filter&quot;&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/a&gt; is a built-in function that allows you to process an iterable and extract those items that satisfy a given condition. This process is commonly known as a &lt;strong&gt;filtering&lt;/strong&gt; operation. With &lt;code&gt;filter()&lt;/code&gt;, you can apply a &lt;strong&gt;filtering function&lt;/strong&gt; to an iterable and produce a new iterable with the items that satisfy the condition at hand. In Python, &lt;code&gt;filter()&lt;/code&gt; is one of the tools that you can use for &lt;a href=&quot;https://realpython.com/python-functional-programming/&quot;&gt;functional programming&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/strong&gt; in your code&lt;/li&gt;
&lt;li&gt;Extract &lt;strong&gt;needed values&lt;/strong&gt; from your iterables&lt;/li&gt;
&lt;li&gt;Combine &lt;code&gt;filter()&lt;/code&gt; with other &lt;strong&gt;functional tools&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Replace&lt;/strong&gt; &lt;code&gt;filter()&lt;/code&gt; with more &lt;strong&gt;Pythonic&lt;/strong&gt; tools&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this knowledge, you&amp;rsquo;ll be able to use &lt;code&gt;filter()&lt;/code&gt; effectively in your code. Alternatively, you have the choice of using &lt;a href=&quot;https://realpython.com/list-comprehension-python/&quot;&gt;list comprehensions&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/introduction-to-python-generators/#building-generators-with-generator-expressions&quot;&gt;generator expressions&lt;/a&gt; to write more &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;Pythonic&lt;/a&gt; and readable code.&lt;/p&gt;
&lt;p&gt;To better understand &lt;code&gt;filter()&lt;/code&gt;, it would be helpful for you to have some previous knowledge on &lt;a href=&quot;https://realpython.com/python-iterators-iterables/#getting-to-know-python-iterables&quot;&gt;iterables&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-lambda/&quot;&gt;&lt;code&gt;lambda&lt;/code&gt; functions&lt;/a&gt;. You can also refresh your memory of lambda functions through a &lt;a href=&quot;https://realpython.com/courses/python-lambda-functions/&quot;&gt;video course&lt;/a&gt;.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Round Numbers in Python</title>
      <id>https://realpython.com/python-rounding/</id>
      <link href="https://realpython.com/python-rounding/"/>
      <updated>2023-07-03T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn what kinds of mistakes you might make when rounding numbers and how you can best manage or avoid them. It’s a great place to start for the early-intermediate Python developer interested in using Python for finance, data science, or scientific computing.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;With many businesses &lt;a href=&quot;https://stackoverflow.blog/2017/09/14/python-growing-quickly/&quot;&gt;turning to Python’s powerful data science ecosystem&lt;/a&gt; to analyze their data, understanding how to avoid introducing bias into datasets is absolutely vital. If you’ve studied some statistics, then you’re probably familiar with terms like reporting bias, selection bias, and sampling bias. There’s another type of bias that plays an important role when you’re dealing with numeric data: rounding bias. &lt;/p&gt;
&lt;p&gt;Understanding how rounding works in Python can help you avoid biasing your dataset. This is an important skill. After all, drawing conclusions from biased data can lead to costly mistakes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why the way you round numbers is important&lt;/li&gt;
&lt;li&gt;How to round a number according to &lt;strong&gt;various rounding strategies&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;implement&lt;/strong&gt; each strategy in pure Python&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;rounding affects data&lt;/strong&gt; and which rounding strategy &lt;strong&gt;minimizes this effect&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to round numbers in &lt;strong&gt;NumPy arrays&lt;/strong&gt; and &lt;strong&gt;pandas DataFrames&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;When to apply different rounding strategies&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;&lt;i class=&quot;fa fa-graduation-cap&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt; Take the Quiz:&lt;/strong&gt; Test your knowledge with our interactive “Rounding Numbers in Python” quiz. Upon completion you will receive a score so you can track your learning progress over time:&lt;/p&gt;&lt;p class=&quot;text-center my-2&quot;&gt;&lt;a class=&quot;btn btn-primary&quot; href=&quot;/quizzes/python-rounding/&quot; target=&quot;_blank&quot;&gt;Take the Quiz »&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-rounding-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-rounding-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download sample code&lt;/a&gt; to ensure that your numbers are always well rounded!&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You won’t get a treatise on numeric precision in computing, although you’ll touch briefly on the subject. Only a familiarity with the &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;fundamentals of Python&lt;/a&gt; is necessary, and the math should feel familiar if you’ve had high school algebra.&lt;/p&gt;
&lt;p&gt;You’ll start by looking at Python’s built-in rounding mechanism.&lt;/p&gt;
&lt;h2 id=&quot;pythons-built-in-round-function&quot;&gt;Python’s Built-in &lt;code&gt;round()&lt;/code&gt; Function&lt;a class=&quot;headerlink&quot; href=&quot;#pythons-built-in-round-function&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python has a built-in &lt;code&gt;round()&lt;/code&gt; function that takes two numeric arguments, &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;ndigits&lt;/code&gt;, and returns the &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt; &lt;code&gt;n&lt;/code&gt; rounded to &lt;code&gt;ndigits&lt;/code&gt;. The &lt;code&gt;ndigits&lt;/code&gt; argument defaults to zero, so leaving it out results in a number rounded to an integer. As you’ll see, &lt;code&gt;round()&lt;/code&gt; may not work quite as you expect.&lt;/p&gt;
&lt;p&gt;The way most people are taught to round a number goes something like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Round the number &lt;code&gt;n&lt;/code&gt; to &lt;code&gt;p&lt;/code&gt; decimal places by first shifting the decimal point in &lt;code&gt;n&lt;/code&gt; by &lt;code&gt;p&lt;/code&gt; places. To do that, multiply &lt;code&gt;n&lt;/code&gt; by 10ᵖ (10 raised to the &lt;code&gt;p&lt;/code&gt; power) to get a new number, &lt;code&gt;m&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then look at the digit &lt;code&gt;d&lt;/code&gt; in the first decimal place of &lt;code&gt;m&lt;/code&gt;. If &lt;code&gt;d&lt;/code&gt; is less than 5, round &lt;code&gt;m&lt;/code&gt; down to the nearest integer. Otherwise, round &lt;code&gt;m&lt;/code&gt; up.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, shift the decimal point back &lt;code&gt;p&lt;/code&gt; places by dividing &lt;code&gt;m&lt;/code&gt; by 10ᵖ.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s an algorithm! For example, the number &lt;code&gt;2.5&lt;/code&gt; rounded to the nearest whole number is &lt;code&gt;3&lt;/code&gt;. The number &lt;code&gt;1.64&lt;/code&gt; rounded to one decimal place is &lt;code&gt;1.6&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now open up an interpreter session and round &lt;code&gt;2.5&lt;/code&gt; to the nearest whole number using Python’s built-in &lt;a href=&quot;https://docs.python.org/3/library/functions.html#round&quot;&gt;&lt;code&gt;round()&lt;/code&gt;&lt;/a&gt; function:&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;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;2.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Gasp!&lt;/p&gt;
&lt;p&gt;Check out how &lt;code&gt;round()&lt;/code&gt; handles the number &lt;code&gt;1.5&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;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So, &lt;code&gt;round()&lt;/code&gt; rounds &lt;code&gt;1.5&lt;/code&gt; up to &lt;code&gt;2&lt;/code&gt;, and &lt;code&gt;2.5&lt;/code&gt; down to &lt;code&gt;2&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;Before you go raising an issue on the Python bug tracker, rest assured you that &lt;code&gt;round(2.5)&lt;/code&gt; is &lt;em&gt;supposed&lt;/em&gt; to return &lt;code&gt;2&lt;/code&gt;. There’s a good reason why &lt;code&gt;round()&lt;/code&gt; behaves the way it does.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn that there are more ways to round a number than you might expect, each with unique advantages and disadvantages. &lt;code&gt;round()&lt;/code&gt; behaves according to a particular rounding strategy—which may or may not be the one you need for a given situation.&lt;/p&gt;
&lt;p&gt;You might be wondering, &lt;em&gt;Can the way I round numbers really have that much of an impact?&lt;/em&gt; Next up, take a look at just how extreme the effects of rounding can be.&lt;/p&gt;
&lt;h2 id=&quot;how-much-impact-can-rounding-have&quot;&gt;How Much Impact Can Rounding Have?&lt;a class=&quot;headerlink&quot; href=&quot;#how-much-impact-can-rounding-have&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Suppose you have an incredibly lucky day and find $100 on the ground. Rather than spending all your money at once, you decide to play it smart and invest your money by buying some shares of different stocks.&lt;/p&gt;
&lt;p&gt;The value of a stock depends on supply and demand. The more people there are who want to buy a stock, the more value that stock has, and vice versa. In high-volume stock markets, the value of a particular stock can fluctuate on a second-by-second basis.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-rounding/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-rounding/ »&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 #162: Exploring the Zen of Python &amp; pandas Features for Finance</title>
      <id>https://realpython.com/podcasts/rpp/162/</id>
      <link href="https://realpython.com/podcasts/rpp/162/"/>
      <updated>2023-06-30T12:00:00+00:00</updated>
      <summary>What advice can you extract from the Zen of Python? How can these nineteen guiding principles help you write more idiomatic Python? 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;What advice can you extract from the Zen of Python? How can these nineteen guiding principles help you write more idiomatic Python? 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>Why Are Membership Tests So Fast for range() in Python?</title>
      <id>https://realpython.com/python-range-membership-test/</id>
      <link href="https://realpython.com/python-range-membership-test/"/>
      <updated>2023-06-28T14:00:00+00:00</updated>
      <summary>In Python, range() is most commonly used in for loops. However, ranges have some other use cases too, as they share many properties with lists. In this tutorial, you&#x27;ll explore why it&#x27;s so fast to perform a membership test on a Python range.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In Python, &lt;code&gt;range()&lt;/code&gt; is most commonly used in &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt; to iterate over a known range of numbers. But that’s not all it can do! There are other interesting uses of &lt;code&gt;range()&lt;/code&gt;. For example, you can pick out elements of a range or check whether a given number belongs to a range of numbers. The latter operation is known as a &lt;strong&gt;membership test&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Python’s &lt;code&gt;range()&lt;/code&gt; objects support most of the operations that you’ve come to expect from &lt;a href=&quot;https://realpython.com/python-lists-tuples/#python-lists&quot;&gt;lists&lt;/a&gt;. For example, you can calculate the total &lt;a href=&quot;https://realpython.com/len-python-function/&quot;&gt;length&lt;/a&gt;, pick out a number at a given &lt;a href=&quot;https://realpython.com/python-lists-tuples/#list-elements-can-be-accessed-by-index&quot;&gt;index&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-iterators-iterables/&quot;&gt;iterate&lt;/a&gt; over each element in a range. Assume that you have a range of the first ten million integers and a list with the same numbers:&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;numbers_as_range&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10_000_000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers_as_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers_as_range&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;For many operations, you can treat these objects as interchangeable. Both ranges and lists support indexing items and calculating length:&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;numbers_as_range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;123&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;123&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;numbers_as_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;123&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;123&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;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers_as_range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;10000000&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;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers_as_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;10000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Additionally, you can iterate over each object or check if a certain element is a member. For example, you can use the &lt;a href=&quot;https://realpython.com/python-in-operator/&quot;&gt;&lt;code&gt;in&lt;/code&gt; operator&lt;/a&gt; to check whether &lt;code&gt;-1&lt;/code&gt; is part of any of these containers:&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;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers_as_range&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;False&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;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers_as_list&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 range and the list only include non-negative numbers, &lt;code&gt;-1&lt;/code&gt; is not a member. However, the time Python takes to figure this out is vastly different for the two data structures:&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;timeit&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeit&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;timeit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-1 in numbers_as_range&quot;&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;o&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;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;4.68301093652801e-06&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;timeit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-1 in numbers_as_list&quot;&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;o&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;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;5.704572553362310&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, you use &lt;code&gt;timeit&lt;/code&gt; to measure the &lt;a href=&quot;https://realpython.com/python-timer/&quot;&gt;running time of the code&lt;/a&gt;. The reported numbers indicate how many seconds Python spent executing each command a hundred times.&lt;/p&gt;
&lt;p&gt;Note the &lt;code&gt;e-06&lt;/code&gt; suffix in the first number. It’s scientific notation that means that the number in front of the suffix represents microseconds. If you compare the numbers, then you’ll see that searching for—and not finding—an element is several orders of magnitude slower in the list than in the range object.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll investigate how &lt;code&gt;range()&lt;/code&gt; works under the hood and learn &lt;strong&gt;why Python’s &lt;code&gt;range()&lt;/code&gt; membership tests are so fast&lt;/strong&gt;. If you want to brush up on how to work with &lt;code&gt;range()&lt;/code&gt;, then you should have a look at &lt;a href=&quot;https://realpython.com/python-range/&quot;&gt;The Python &lt;code&gt;range()&lt;/code&gt; Function&lt;/a&gt; first. You can click the link below to download some example code that you’ll be exploring in this tutorial:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-range-membership-test-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-range-membership-test-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 explore how Python runs such quick membership tests on &lt;code&gt;range()&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;in-short-a-formula-determines-membership-in-a-python-range&quot;&gt;In Short: A Formula Determines Membership in a Python Range&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-a-formula-determines-membership-in-a-python-range&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python, three numbers define a range: &lt;strong&gt;&lt;code&gt;start&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;stop&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;code&gt;step&lt;/code&gt;&lt;/strong&gt;. The range will begin at &lt;code&gt;start&lt;/code&gt; and then contain every &lt;code&gt;step&lt;/code&gt; integer that’s smaller than &lt;code&gt;stop&lt;/code&gt;. For example, if &lt;code&gt;start = 1&lt;/code&gt;, &lt;code&gt;stop = 10&lt;/code&gt;, and &lt;code&gt;step = 2&lt;/code&gt;, then the range will be the odd numbers less than ten. Namely, one, three, five, seven, and nine.&lt;/p&gt;
&lt;p&gt;A list is much more flexible. It can contain any number of elements, and the elements can be of any type. It’s possible to have repeated elements. A list is often not sorted. In fact, it’s possible to have lists that Python can’t order, as the elements can be of mixed types that aren’t comparable.&lt;/p&gt;
&lt;p&gt;All this flexibility has a price. To check if a list contains a particular element, Python needs to look through the list—one element at a time—until it finds a match. In principle, the operation looks something like this:&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;list_contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_element&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list_element&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;True&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;False&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This function loops over all the list elements until it finds a match. If that match happens to be one of the first elements in the list, then it returns quickly. But if &lt;code&gt;element&lt;/code&gt; isn’t in the list, then the function needs to inspect all the elements in the list to reach this conclusion.&lt;/p&gt;
&lt;p&gt;If you’re working with ranges, then Python can take a shortcut and use a formula instead. With the following function, you can implement such a calculation:&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range_contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;step&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;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&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;step&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-range-membership-test/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-range-membership-test/ »&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>Jinja Templating</title>
      <id>https://realpython.com/courses/jinja-templating/</id>
      <link href="https://realpython.com/courses/jinja-templating/"/>
      <updated>2023-06-27T14:00:00+00:00</updated>
      <summary>With Jinja, you can build rich templates that power the front end of your web applications. But you can use Jinja without a web framework running in the background. Anytime you want to create text files with programmatic content, Jinja can help you out.</summary>
      <content type="html">
        &lt;p&gt;Templates are an essential ingredient in full-stack web development.
With &lt;strong&gt;Jinja&lt;/strong&gt;, you can build rich templates that power the front end of your Python web applications.&lt;/p&gt;
&lt;p&gt;Jinja is a text templating language. It allows you to process a block of text, insert values from a context dictionary, control how the text flows using conditionals and loops, modify inserted data with filters, and compose different templates together using inheritance and inclusion.&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;Install the Jinja &lt;strong&gt;template engine&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create your first Jinja &lt;strong&gt;template&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Render a Jinja template in &lt;strong&gt;Flask&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/strong&gt; and &lt;strong&gt;conditional statements&lt;/strong&gt; with Jinja&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nest&lt;/strong&gt; Jinja templates&lt;/li&gt;
&lt;li&gt;Modify variables in Jinja with &lt;strong&gt;filters&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;macros&lt;/strong&gt; to add functionality to your front end&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is for you if you want to learn more about the Jinja template language or if you&amp;rsquo;re getting started with Flask.&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 #161: Resources and Advice for Building CircuitPython Projects</title>
      <id>https://realpython.com/podcasts/rpp/161/</id>
      <link href="https://realpython.com/podcasts/rpp/161/"/>
      <updated>2023-06-23T12:00:00+00:00</updated>
      <summary>Are you looking to advance your CircuitPython projects? Would you like a collection of resources and tools to help you along your path? This week on the show, Tod Kurt is here to discuss building projects with CircuitPython.</summary>
      <content type="html">
        &lt;p&gt;Are you looking to advance your CircuitPython projects? Would you like a collection of resources and tools to help you along your path? This week on the show, Tod Kurt is here to discuss building projects with CircuitPython.&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>Recursion in Python</title>
      <id>https://realpython.com/courses/python-recursion/</id>
      <link href="https://realpython.com/courses/python-recursion/"/>
      <updated>2023-06-20T14:00:00+00:00</updated>
      <summary>A recursive function is one that calls itself. In this video course, you&#x27;ll see what recursion is, how it works in Python, and under what circumstances you should use it.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re familiar with &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions in Python&lt;/a&gt;, then you know that it&amp;rsquo;s quite common for one function to call another. In Python, it&amp;rsquo;s also possible for a function to call itself!  A function that calls itself is said to be &lt;strong&gt;recursive&lt;/strong&gt;, and the technique of employing a recursive function is called &lt;strong&gt;recursion&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It may seem peculiar for a function to call itself, but many types of programming problems are best expressed recursively. When you bump up against such a problem, recursion is an indispensable tool for you to have in your toolkit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll understand:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What it means for a function to call itself &lt;strong&gt;recursively&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;When recursion might be your &lt;strong&gt;best best&lt;/strong&gt; for solving a problem&lt;/li&gt;
&lt;li&gt;How you can &lt;strong&gt;implement recursion&lt;/strong&gt; for various use cases in Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you&amp;rsquo;ll study several specific programming tasks where you can use recursion in Python. You&amp;rsquo;ll also explore alternatives to recursion.&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 #160: Inheriting a Large Python Code Base &amp; Building a GUI With Kivy</title>
      <id>https://realpython.com/podcasts/rpp/160/</id>
      <link href="https://realpython.com/podcasts/rpp/160/"/>
      <updated>2023-06-16T12:00:00+00:00</updated>
      <summary>What are the unique challenges of a large Python code base? What techniques can you implement to simplify the management of a big project? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What are the unique challenges of a large Python code base? What techniques can you implement to simplify the management of a big project? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Reading and Writing Files</title>
      <id>https://realpython.com/courses/python-reading-and-writing-files/</id>
      <link href="https://realpython.com/courses/python-reading-and-writing-files/"/>
      <updated>2023-06-13T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to move data back and forth between your Python programs and external software by reading and writing files. You&#x27;ll practice reading and writing data stored in the CSV file format, one of the most widely supported file formats for transferring tabular data.</summary>
      <content type="html">
        &lt;p&gt;Files are everywhere in the modern world. They&amp;rsquo;re the medium in which data is digitally stored and transferred. Chances are, you&amp;rsquo;ve opened dozens, if not hundreds, of files just today! Now it&amp;rsquo;s time to read and write files with Python.&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;Understand the difference between &lt;strong&gt;text&lt;/strong&gt; and &lt;strong&gt;binary&lt;/strong&gt; files&lt;/li&gt;
&lt;li&gt;Learn about &lt;strong&gt;character encodings&lt;/strong&gt; and &lt;strong&gt;line endings&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Work with &lt;strong&gt;file objects&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Read and write character data in various &lt;strong&gt;file modes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;open()&lt;/code&gt;, &lt;code&gt;Path.open()&lt;/code&gt;, and the &lt;code&gt;with&lt;/code&gt; statement&lt;/li&gt;
&lt;li&gt;Take advantage of the &lt;code&gt;csv&lt;/code&gt; module to manipulate &lt;strong&gt;CSV data&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. You can also check out the other &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics courses&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course. If you&amp;rsquo;re just getting started, then you might want to check out &lt;a href=&quot;https://realpython.com/courses/setting-up-python/&quot;&gt;Python Basics: Setting Up Python&lt;/a&gt; before diving into this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #159: Volunteering, Organizing, and Finding a Python Community</title>
      <id>https://realpython.com/podcasts/rpp/159/</id>
      <link href="https://realpython.com/podcasts/rpp/159/"/>
      <updated>2023-06-09T12:00:00+00:00</updated>
      <summary>Have you thought about getting more involved in the Python community? Are you interested in volunteering for an event or becoming an organizer? This week on the show, we speak with organizers from this year&#x27;s PyCascades conference about making connections, learning new skills, and rationing your time.</summary>
      <content type="html">
        &lt;p&gt;Have you thought about getting more involved in the Python community? Are you interested in volunteering for an event or becoming an organizer? This week on the show, we speak with organizers from this year&#x27;s PyCascades conference about making connections, learning new skills, and rationing your time.&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>Mazes in Python Part 1: Building and Visualizing</title>
      <id>https://realpython.com/courses/python-maze-solver-part-1/</id>
      <link href="https://realpython.com/courses/python-maze-solver-part-1/"/>
      <updated>2023-06-06T14:00:00+00:00</updated>
      <summary>In part one of this two-part project, you&#x27;ll design your maze and represent it in an object-oriented way. You&#x27;ll also visualize the maze and its solution using scalable vector graphics (SVG).</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re up for a little challenge and would like to take your programming skills to the next level, then you&amp;rsquo;ve come to the right place! In this hands-on video course, you&amp;rsquo;ll practice object-oriented programming, among several other good practices, while building a cool maze solver project in Python.&lt;/p&gt;
&lt;p&gt;This is the first part in a two-part series. Throughout the series, you&amp;rsquo;ll go step by step through the guided process of building a complete and working project. This will include reading a maze from a binary file, visualizing it using scalable vector graphics (SVG), and finding the shortest path from the entrance to the exit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In part one of the series, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use an &lt;strong&gt;object-oriented approach&lt;/strong&gt; to represent the maze in memory&lt;/li&gt;
&lt;li&gt;Visualize the maze and its solution using &lt;strong&gt;scalable vector graphics (SVG)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;ve already completed this video course, then you can jump ahead to &lt;a href=&quot;https://realpython.com/courses/python-maze-solver-part-2/&quot;&gt;Mazes in Python Part 2: Storing and Solving&lt;/a&gt;, where you&amp;rsquo;ll complete the project by creating a binary storage format for mazes and solving mazes using NetworkX.&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 #158: Building Python CI With Docker &amp; Applying for a Hacker Initiative Grant</title>
      <id>https://realpython.com/podcasts/rpp/158/</id>
      <link href="https://realpython.com/podcasts/rpp/158/"/>
      <updated>2023-06-02T12:00:00+00:00</updated>
      <summary>Do you need a refresher on using Docker with Python? Would you like to learn how to configure a continuous integration pipeline with modern tools and Docker? 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;Do you need a refresher on using Docker with Python? Would you like to learn how to configure a continuous integration pipeline with modern tools and Docker? 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>Getting the First Match From a Python List or Iterable</title>
      <id>https://realpython.com/courses/python-first-match/</id>
      <link href="https://realpython.com/courses/python-first-match/"/>
      <updated>2023-05-30T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about the best ways to get the first match from a Python list or iterable. You&#x27;ll look into two different strategies, for loops and generators, and compare their performance. Then you&#x27;ll finish up by creating a reusable function for all your first matching needs.</summary>
      <content type="html">
        &lt;p&gt;At some point in your Python journey, you may need to find the &lt;strong&gt;first item that matches a certain criterion&lt;/strong&gt; in a Python &lt;a href=&quot;https://realpython.com/python-for-loop/#iterables&quot;&gt;iterable&lt;/a&gt;, such as a &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The simplest case is that you need to confirm that a particular item exists in the iterable. For example, you want to find a name in a list of names or a &lt;a href=&quot;https://realpython.com/python-string-contains-substring/&quot;&gt;substring inside a string&lt;/a&gt;. In these cases, you&amp;rsquo;re best off using the &lt;code&gt;in&lt;/code&gt; operator. However, there are many use cases when you may want to look for items with specific properties. For instance, you may need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Find a non-zero value in a list of &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Find a name of a particular length in a list of &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Find and modify a dictionary in a list of dictionaries based on a certain attribute&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll explore how best to approach all three scenarios.&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 #157: Discussing Mojo &amp; Improving Python Object-Oriented Programming</title>
      <id>https://realpython.com/podcasts/rpp/157/</id>
      <link href="https://realpython.com/podcasts/rpp/157/"/>
      <updated>2023-05-26T12:00:00+00:00</updated>
      <summary>Would you like to speed up your Python machine-learning code dramatically? What if you only had to change a few keywords and add a couple of type hints on portions of 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;Would you like to speed up your Python machine-learning code dramatically? What if you only had to change a few keywords and add a couple of type hints on portions of 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 k-Nearest Neighbors (kNN) in Python</title>
      <id>https://realpython.com/courses/knn-python/</id>
      <link href="https://realpython.com/courses/knn-python/"/>
      <updated>2023-05-23T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn all about the k-nearest neighbors (kNN) algorithm in Python, including how to implement kNN from scratch. Once you understand how kNN works, you&#x27;ll use scikit-learn to facilitate your coding process.</summary>
      <content type="html">
        &lt;p&gt;In this video course, you&amp;rsquo;ll get a thorough introduction to the k-Nearest Neighbors (kNN) algorithm in Python. The kNN algorithm is one of the most famous &lt;a href=&quot;https://realpython.com/learning-paths/machine-learning-python/&quot;&gt;machine learning&lt;/a&gt; algorithms and an absolute must-have in your machine learning toolbox. Python is the go-to programming language for machine learning, so what better way to discover kNN than with Python&amp;rsquo;s famous packages &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; and &lt;a href=&quot;https://scikit-learn.org/stable/&quot;&gt;scikit-learn&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll explore the kNN algorithm both in theory and in practice. It&amp;rsquo;s important to learn about the mechanics of machine learning algorithms to understand their potential and limitations. At the same time, it&amp;rsquo;s essential to understand how to use an algorithm in practice. With that in mind, you&amp;rsquo;ll also focus on the use of kNN in the Python library scikit-learn.&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;Explain the &lt;strong&gt;kNN algorithm&lt;/strong&gt; both intuitively and mathematically&lt;/li&gt;
&lt;li&gt;Implement kNN in Python &lt;strong&gt;from scratch&lt;/strong&gt; using &lt;strong&gt;NumPy&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use kNN in Python with &lt;strong&gt;scikit-learn&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>
  

</feed>
