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

  
    <entry>
      <title>Modern Web Automation With Python and Selenium</title>
      <id>https://realpython.com/modern-web-automation-with-python-and-selenium/</id>
      <link href="https://realpython.com/modern-web-automation-with-python-and-selenium/"/>
      <updated>2025-04-30T14:00:00+00:00</updated>
      <summary>Learn advanced Python web automation techniques with Selenium, such as headless browsing, interacting with web elements, and implementing the Page Object Model pattern.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Selenium is a web automation tool that allows you to use Python to programmatically interact with dynamic, JavaScript-generated web pages. Your Python Selenium code drives a real browser that you can instruct to fill out forms, click buttons, scrape dynamically generated data, or write automated tests for web applications.&lt;/p&gt;
&lt;p&gt;By implementing the Page Object Model (POM) design pattern, you can create clean and scalable automation scripts that are straightforward to read and maintain.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Selenium&lt;/strong&gt; allows you to launch browsers, visit URLs, and interact with web elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Headless browsers&lt;/strong&gt; let you run scripts without displaying a browser window, which is useful for automation and testing.&lt;/li&gt;
&lt;li&gt;You can target web elements using different &lt;strong&gt;locators&lt;/strong&gt;, such as CSS selectors, XPath, or IDs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Explicit waits&lt;/strong&gt; provide a flexible way to handle dynamic content by waiting for specific conditions.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Page Object Model&lt;/strong&gt; design pattern separates page structure from business logic.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, you’ll learn how to use Selenium with Python to build a fully functional music player that interacts with Bandcamp’s &lt;em&gt;Discover&lt;/em&gt; page. You’ll control the player from the command line while a headless Firefox browser runs in the background. With it, you’ll be able to play tracks, pause music, list available tracks, and load more tracks, replicating some of the website’s core functionality.&lt;/p&gt;
&lt;p&gt;Along the way, you’ll learn modern best practices, like implementing the &lt;strong&gt;Page Object Model (POM)&lt;/strong&gt;, which helps keep your automation scripts clean, testable, and maintainable. Ready to get started? Head over to &lt;a href=&quot;https://bandcamp.com/discover/&quot;&gt;bandcamp.com/discover/&lt;/a&gt; and play some of the available music to get a feel for the website and pump up your mood for this project!&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-selenium-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-selenium-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use Selenium in Python for modern web automation.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Web Automation With Python and Selenium” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-selenium/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #b9abe6;&quot; alt=&quot;Modern Web Automation with Python and Selenium&quot; src=&quot;https://files.realpython.com/media/Modern-Web-Automation-With-Python-and-Selenium_Watermarked.08e8e08b976d.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Modern-Web-Automation-With-Python-and-Selenium_Watermarked.08e8e08b976d.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Modern-Web-Automation-With-Python-and-Selenium_Watermarked.08e8e08b976d.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Modern-Web-Automation-With-Python-and-Selenium_Watermarked.08e8e08b976d.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Modern-Web-Automation-With-Python-and-Selenium_Watermarked.08e8e08b976d.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-selenium/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Web Automation With Python and Selenium&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of using Selenium with Python for web automation. You&#x27;ll revisit concepts like launching browsers, interacting with web elements, handling dynamic content, and implementing the Page Object Model (POM) design pattern.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;understand-the-project-and-approach&quot;&gt;Understand the Project and Approach&lt;a class=&quot;headerlink&quot; href=&quot;#understand-the-project-and-approach&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Web automation&lt;/strong&gt; involves using a script to drive a browser and perform actions such as clicking links, filling out forms, and gathering data. Instead of manually navigating a website, you can delegate these tasks to Python. A typical scenario is automating repetitive tasks, such as logging in daily to a tool or scraping regularly updated data.&lt;/p&gt;
&lt;p&gt;Because many web apps are built for human interaction, they can present challenges when you try to interact with them automatically. In the early days of the internet, you could send HTTP requests and parse the resulting HTML. But modern sites often rely on &lt;a href=&quot;https://realpython.com/python-vs-javascript/&quot;&gt;JavaScript&lt;/a&gt; to handle events or generate content dynamically, meaning that an HTTP request alone probably won’t reveal the full page content. That’s where &lt;strong&gt;Selenium&lt;/strong&gt; comes in.&lt;/p&gt;
&lt;h3 id=&quot;the-selenium-project&quot;&gt;The Selenium Project&lt;a class=&quot;headerlink&quot; href=&quot;#the-selenium-project&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Selenium is a mature open-source project that provides a convenient API to control browsers. With Selenium, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Launch a headless or visible browser such as Firefox or Chrome using a &lt;strong&gt;web driver&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Visit URLs and navigate pages just like a real user would.&lt;/li&gt;
&lt;li&gt;Locate elements with CSS selectors, XPath, or similar locators.&lt;/li&gt;
&lt;li&gt;Interact with elements by clicking, typing, dragging, or waiting for them to change.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you install the appropriate driver for your browser, you can control your browser through a script using Selenium.&lt;/p&gt;
&lt;p&gt;Selenium itself is written in &lt;a href=&quot;https://realpython.com/java-vs-python/&quot;&gt;Java&lt;/a&gt;, but has bindings for different programming languages. In Python, it’s distributed on &lt;span data-invalid-ref=&quot;glossary/PyPI&quot;&gt;PyPI&lt;/span&gt; as a single package called &lt;code&gt;selenium&lt;/code&gt;, which you can install using &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Selenium is often used for automated testing, but it’s equally useful for generic web automation, which is what this tutorial will focus on.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You might be wondering how Selenium differs from other tools for scripted web interactions, such as &lt;a href=&quot;https://realpython.com/beautiful-soup-web-scraper-python/&quot;&gt;Beautiful Soup&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/web-scraping-with-scrapy-and-mongodb/&quot;&gt;Scrapy&lt;/a&gt;, or &lt;a href=&quot;https://realpython.com/python-requests/&quot;&gt;Requests&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One central difference is that those tools are great at handling static data, while Selenium allows you to replicate user behavior at the JavaScript level. This means that you can interact with dynamically generated web content using Selenium.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Before diving into the nuts and bolts of Selenium, it’s helpful to get a clear picture of what you’ll build by the end of this tutorial. As mentioned, you’ll create a fully functional, console-based music player that interacts with the &lt;a href=&quot;https://bandcamp.com/discover/&quot;&gt;Bandcamp &lt;em&gt;Discover&lt;/em&gt; page&lt;/a&gt; using a headless Firefox browser.&lt;/p&gt;
&lt;h3 id=&quot;your-bandcamp-discover-music-player&quot;&gt;Your Bandcamp Discover Music Player&lt;a class=&quot;headerlink&quot; href=&quot;#your-bandcamp-discover-music-player&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Bandcamp is a popular online record store and music community where you can stream songs, explore artists, and discover new albums.&lt;/p&gt;
&lt;p&gt;Selenium allows you to automate direct interactions with Bandcamp’s web interface—as though you were clicking and scrolling yourself!&lt;/p&gt;
&lt;p&gt;Your finished project will open the Bandcamp Discover page in the background, which means you won’t get to see any of the wonderful album artwork:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/bandcamp-discover-page.710ecc243348.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block &quot; src=&quot;https://files.realpython.com/media/bandcamp-discover-page.710ecc243348.png&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/bandcamp-discover-page.710ecc243348.png 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/bandcamp-discover-page.710ecc243348.png 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/bandcamp-discover-page.710ecc243348.png 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/bandcamp-discover-page.710ecc243348.png 1920w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;A view of the Bandcamp Discover page that shows album artwork, a player, and genre selection buttons on the top&quot; data-asset=&quot;6299&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;If a browser automation tool creates a browser instance without a visible browser window, it’s said to run in &lt;strong&gt;headless&lt;/strong&gt; mode. But don’t lose your head over that word—your code will stay calm and in control!&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/modern-web-automation-with-python-and-selenium/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/modern-web-automation-with-python-and-selenium/ »&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>Quiz: Web Automation With Python and Selenium</title>
      <id>https://realpython.com/quizzes/python-selenium/</id>
      <link href="https://realpython.com/quizzes/python-selenium/"/>
      <updated>2025-04-30T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of using Selenium with Python for web automation. You&#x27;ll revisit concepts like launching browsers, interacting with web elements, handling dynamic content, and implementing the Page Object Model (POM) design pattern.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of
&lt;a href=&quot;https://realpython.com/modern-web-automation-with-python-and-selenium/&quot;&gt;Web Automation With Python and Selenium&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit concepts like launching browsers, interacting with web elements, handling dynamic content, and implementing the Page Object Model (POM) design pattern.&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>Thread Safety in Python: Locks and Other Techniques</title>
      <id>https://realpython.com/courses/thread-safety-locks-other-techniques/</id>
      <link href="https://realpython.com/courses/thread-safety-locks-other-techniques/"/>
      <updated>2025-04-29T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about the issues that can occur when your code is run in a multithreaded environment. Then you&#x27;ll explore the various synchronization primitives available in Python&#x27;s threading module, such as locks, which help you make your code safe.</summary>
      <content type="html">
        &lt;p&gt;Threads share state in your programs, which means race conditions can be created when two or more threads fight to update a value. This course is about the various primitives you can use to ensure atomic access to your program&amp;rsquo;s shared state.&lt;/p&gt;
&lt;p&gt;By the end of this video course, you&amp;rsquo;ll be able to identify safety issues and prevent them by using the synchronization primitives in Python&amp;rsquo;s &lt;code&gt;threading&lt;/code&gt; module to make your code thread-safe.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;thread safety&lt;/strong&gt; is&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;race conditions&lt;/strong&gt; are and how to avoid them&lt;/li&gt;
&lt;li&gt;How to identify &lt;strong&gt;thread safety issues&lt;/strong&gt; in your code&lt;/li&gt;
&lt;li&gt;What different &lt;strong&gt;synchronization primitives&lt;/strong&gt; exist in the &lt;code&gt;threading&lt;/code&gt; module&lt;/li&gt;
&lt;li&gt;How to use synchronization primitives to &lt;strong&gt;make your code thread-safe&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Managing Python Projects With uv: An All-in-One Solution</title>
      <id>https://realpython.com/python-uv/</id>
      <link href="https://realpython.com/python-uv/"/>
      <updated>2025-04-28T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to create and manage your Python projects using uv, an extremely fast Python package and project manager written in Rust.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The uv tool is a high-speed package and project manager for Python. It’s written in Rust and designed to streamline your workflow. It offers fast dependency installation and integrates various functionalities into a single tool.&lt;/p&gt;
&lt;p&gt;With uv, you can install and manage multiple Python versions, create virtual environments, efficiently handle project dependencies, reproduce working environments, and even build and publish a project. These capabilities make uv an all-in-one tool for Python project management.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;uv is a Python package and project manager&lt;/strong&gt; that integrates multiple functionalities into one tool, offering a comprehensive solution for managing Python projects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;uv is used for fast dependency installation&lt;/strong&gt;, virtual environment management, Python version management, and project initialization, enhancing productivity and efficiency.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;uv can build and publish Python packages&lt;/strong&gt; to package repositories like PyPI, supporting a streamlined process from development to distribution.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;uv automatically handles virtual environments&lt;/strong&gt;, creating and managing them as needed to ensure clean and isolated project dependencies.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To dive deeper into managing your Python projects efficiently with uv, you should have a basic understanding of using Python virtual environments, setting up &lt;code&gt;pyproject.toml&lt;/code&gt; files for projects, and building distributable packages for a project.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-uv-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-uv-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; you’ll use to learn about managing Python projects with uv.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Managing Python Projects With uv: An All-in-One Solution” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-uv/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #e5c6aa;&quot; alt=&quot;Managing Python Projects With uv: An All-in-One Solution&quot; src=&quot;https://files.realpython.com/media/Showcase-uv_Watermarked-2.4bbd6b119bc4.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Showcase-uv_Watermarked-2.4bbd6b119bc4.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Showcase-uv_Watermarked-2.4bbd6b119bc4.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Showcase-uv_Watermarked-2.4bbd6b119bc4.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Showcase-uv_Watermarked-2.4bbd6b119bc4.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-uv/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Managing Python Projects With uv: An All-in-One Solution&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of the uv tool, a high-speed package and project manager for Python.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;getting-to-know-uv-for-python&quot;&gt;Getting to Know uv for Python&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-uv-for-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Recently, a few exciting tools built with the &lt;a href=&quot;https://www.rust-lang.org/&quot;&gt;Rust&lt;/a&gt; programming language have appeared in the Python tooling ecosystem. &lt;a href=&quot;https://realpython.com/ruff-python/&quot;&gt;Ruff&lt;/a&gt;—a linter and code formatter for Python—is a well-known and popular example of one of these tools.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll explore another cool tool made with Rust for Python. You’ll get to know &lt;a href=&quot;https://docs.astral.sh/uv/&quot;&gt;uv&lt;/a&gt;, an extremely fast Python &lt;strong&gt;package and project manager&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The main idea behind these tools is to accelerate your Python workflow by speeding up your project management actions. For example, Ruff is 10 to 100 times faster than linters like &lt;a href=&quot;https://flake8.pycqa.org/en/latest/&quot;&gt;Flake8&lt;/a&gt; and code formatters like &lt;a href=&quot;https://black.readthedocs.io/en/stable/&quot;&gt;Black&lt;/a&gt;. Similarly, for package installation, uv is &lt;a href=&quot;https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md&quot;&gt;10 to 100 times faster&lt;/a&gt; than &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Additionally, uv integrates into one tool most of the functionality provided by tools like &lt;code&gt;pip&lt;/code&gt;, &lt;code&gt;pip-tools&lt;/code&gt;, &lt;a href=&quot;https://realpython.com/python-pipx/&quot;&gt;&lt;code&gt;pipx&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/dependency-management-python-poetry/&quot;&gt;&lt;code&gt;poetry&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;&lt;code&gt;pyenv&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://twine.readthedocs.io/en/stable/&quot;&gt;&lt;code&gt;twine&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/#the-virtualenv-project&quot;&gt;&lt;code&gt;virtualenv&lt;/code&gt;&lt;/a&gt;, and more. Therefore, uv is an all-in-one solution.&lt;/p&gt;
&lt;p&gt;Here’s a quick list of key uv features for managing your Python projects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fast dependency installation&lt;/strong&gt;: Installs dependencies really fast, which is especially useful for large dependency trees.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Virtual environment management&lt;/strong&gt;: Automatically creates and manages &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environments&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python version management&lt;/strong&gt;: Allows the installation and management of multiple Python versions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Project initialization&lt;/strong&gt;: Scaffolds a full Python project, including the root directory, &lt;a href=&quot;https://realpython.com/python-git-github-intro/&quot;&gt;Git&lt;/a&gt; repository, virtual environment, &lt;a href=&quot;https://realpython.com/python-pyproject-toml/&quot;&gt;&lt;code&gt;pyproject.toml&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/readme-python-project/&quot;&gt;&lt;code&gt;README&lt;/code&gt;&lt;/a&gt;, and more.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dependency management&lt;/strong&gt;: Installs, updates, removes, and locks direct and &lt;a href=&quot;https://en.wikipedia.org/wiki/Transitive_dependency&quot;&gt;transitive dependencies&lt;/a&gt;, which allows for environment reproducibility.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Package builds and publication management&lt;/strong&gt;: Allows you to build and publish packages to package repositories like the &lt;a href=&quot;/ref/glossary/pypi/&quot; class=&quot;ref-link&quot;&gt;Python Package Index (PyPI)&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Developer tooling support&lt;/strong&gt;: Installs and lets you run development tools, such as &lt;code&gt;pytest&lt;/code&gt;, Black, and Ruff.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Apart from these features, uv is a standalone binary that allows for a smooth installation and quick upgrades. You don’t need to have Python installed on your system to install uv.&lt;/p&gt;
&lt;p&gt;So, with this quick summary of uv and its main features, you’re ready to install this tool on your system. That’s what you’ll do in the following section. Additionally, you’ll learn how to update your uv installation.&lt;/p&gt;
&lt;h2 id=&quot;installing-uv-to-manage-python-projects&quot;&gt;Installing uv to Manage Python Projects&lt;a class=&quot;headerlink&quot; href=&quot;#installing-uv-to-manage-python-projects&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The first step in using any tool is to install it on your operating system. To install uv, you have several options. The quickest one would be to use the standalone installer. Another friendly option is to install uv from &lt;a href=&quot;https://pypi.org&quot;&gt;PyPI&lt;/a&gt; using other tools like &lt;code&gt;pipx&lt;/code&gt; or &lt;a href=&quot;/ref/glossary/pip/&quot; class=&quot;ref-link&quot;&gt;pip&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the official &lt;a href=&quot;https://docs.astral.sh/uv/getting-started/installation/&quot;&gt;uv installation guide&lt;/a&gt;, you’ll find several other installation options. For example, you can use tools like &lt;a href=&quot;https://brew.sh/&quot;&gt;Homebrew&lt;/a&gt; and &lt;a href=&quot;https://doc.rust-lang.org/cargo/&quot;&gt;Cargo&lt;/a&gt;, depending on your current platform and operating system. However, in this tutorial, you’ll only explore the standalone installer and the PyPI options.&lt;/p&gt;
&lt;h3 id=&quot;using-the-standalone-installer&quot;&gt;Using the Standalone Installer&lt;a class=&quot;headerlink&quot; href=&quot;#using-the-standalone-installer&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The uv project provides a standalone installer that you can use to download and install the tool in your system. Below are the relevant commands for the three main operating systems:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-1&quot; role=&quot;tab&quot; aria-controls=&quot;windows-1&quot; aria-selected=&quot;true&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#brands--windows&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Windows&lt;/a&gt;
  &lt;/li&gt;




  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linuxmacos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-macos-1&quot; role=&quot;tab&quot; aria-controls=&quot;linux-macos-1&quot; aria-selected=&quot;false&quot;&gt;&lt;span class=&quot;icon baseline text-muted&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#v4--apple&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-1&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pscon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Windows PowerShell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;PS&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;powershell&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-ExecutionPolicy&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ByPass&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;irm https://astral.sh/uv/install.ps1 | iex&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-macos-tab-1&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-macos-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;curl&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-LsSf&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;https://astral.sh/uv/install.sh&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you don’t have &lt;code&gt;curl&lt;/code&gt; installed on your system, then you can use &lt;code&gt;wget&lt;/code&gt; as shown below:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;wget&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-qO-&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;https://astral.sh/uv/install.sh&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These commands will download and install the latest binary of uv in your system. If you’d like to install a specific version of the tool instead of the latest, then you can add the version number to the download URL right after the &lt;code&gt;uv/&lt;/code&gt; part:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-2&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-2&quot; role=&quot;tab&quot; aria-controls=&quot;windows-2&quot; aria-selected=&quot;true&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#brands--windows&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Windows&lt;/a&gt;
  &lt;/li&gt;




  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linuxmacos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-2&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-macos-2&quot; role=&quot;tab&quot; aria-controls=&quot;linux-macos-2&quot; aria-selected=&quot;false&quot;&gt;&lt;span class=&quot;icon baseline text-muted&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#v4--apple&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-uv/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-uv/ »&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>Quiz: Managing Python Projects With uv: An All-in-One Solution</title>
      <id>https://realpython.com/quizzes/python-uv/</id>
      <link href="https://realpython.com/quizzes/python-uv/"/>
      <updated>2025-04-28T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of the uv tool, a high-speed package and project manager for Python.</summary>
      <content type="html">
        &lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how &lt;a href=&quot;https://realpython.com/python-uv/&quot;&gt;Python&amp;rsquo;s uv&lt;/a&gt; integrates multiple functionalities into one tool, offering a comprehensive solution for managing Python projects.&lt;/p&gt;
&lt;p&gt;You can use it for fast dependency installation, virtual environment management, Python version management, and project initialization, enhancing your productivity and efficiency.&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>Quiz: How to Manage Python Projects With pyproject.toml</title>
      <id>https://realpython.com/quizzes/python-pyproject-toml/</id>
      <link href="https://realpython.com/quizzes/python-pyproject-toml/"/>
      <updated>2025-04-27T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python&#x27;s pyproject.toml file, which simplifies Python project configuration by unifying package setup, managing dependencies, and streamlining builds.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of the &lt;a href=&quot;https://realpython.com/python-pyproject-toml/&quot;&gt;&lt;code&gt;pyproject.toml&lt;/code&gt; file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This file is a key component for defining a Python project&amp;rsquo;s build system, including its requirements and build backend. With appropriate tooling, it can also manage dependencies, optional dependencies, command-line scripts, and dynamic metadata for flexible project configuration.&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 Started With Python IDLE</title>
      <id>https://realpython.com/python-idle/</id>
      <link href="https://realpython.com/python-idle/"/>
      <updated>2025-04-23T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use the development environment included with your Python installation. Python IDLE is a small program that packs a big punch! You&#x27;ll learn how to use Python IDLE to interact with Python directly, work with Python files, and improve your development workflow.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python IDLE is the default integrated development environment (IDE) that comes bundled with every Python installation, helping you to start coding right out of the box. In this tutorial, you’ll explore how to interact with Python directly in IDLE, edit and execute Python files, and even customize the environment to suit your preferences.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Python IDLE&lt;/strong&gt; is completely &lt;strong&gt;free&lt;/strong&gt; and comes packaged with the Python language itself.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python IDLE&lt;/strong&gt; is an IDE included with Python installations, designed for basic editing, execution, and debugging of Python code.&lt;/li&gt;
&lt;li&gt;You &lt;strong&gt;open IDLE&lt;/strong&gt; through your system’s application launcher or terminal, depending on your operating system.&lt;/li&gt;
&lt;li&gt;You can &lt;strong&gt;customize IDLE&lt;/strong&gt; to make it a useful tool for writing Python.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding the basics of Python IDLE will allow you to write, test, and debug Python programs without installing any additional software.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Cheat Sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-idle-cheatsheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-idle-cheatsheet&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download your free cheat sheet&lt;/a&gt; that will help you find the best coding font when starting with IDLE.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;open-pythons-idle-for-the-first-time&quot;&gt;Open Python’s IDLE for the First Time&lt;a class=&quot;headerlink&quot; href=&quot;#open-pythons-idle-for-the-first-time&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python IDLE is free and comes included in Python installations on Windows and macOS. If you’re a Linux user, then you should be able to find and download Python IDLE using your package manager. Once you’ve installed it, you can then open Python IDLE and use it as an interactive interpreter or as a file editor.&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; IDLE stands for “Integrated Development and Learning Environment.” It’s a wordplay with IDE, which stands for Integrated Development Environment.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The procedure for opening IDLE depends on how you installed Python and varies from one operating system to another. Select your operating system below and follow the steps to open IDLE:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-1&quot; role=&quot;tab&quot; aria-controls=&quot;windows-1&quot; aria-selected=&quot;true&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#brands--windows&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Windows&lt;/a&gt;
  &lt;/li&gt;


  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linux&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small &quot; id=&quot;linux-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-1&quot; role=&quot;tab&quot; aria-controls=&quot;linux-1&quot; aria-selected=&quot;false&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Linux&lt;/a&gt;
  &lt;/li&gt;


  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-macos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#macos-1&quot; role=&quot;tab&quot; aria-controls=&quot;macos-1&quot; aria-selected=&quot;false&quot;&gt;&lt;span class=&quot;icon baseline text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#v4--apple&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;macOS&lt;/a&gt;
  &lt;/li&gt;


&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-1&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;p&gt;Open the Start menu and click &lt;em&gt;All Programs&lt;/em&gt; or &lt;em&gt;All Apps&lt;/em&gt;. There should be a program icon labeled &lt;em&gt;IDLE (Python 3.x)&lt;/em&gt;. This will vary slightly between different versions of Windows. The IDLE icon may be in a program group folder named &lt;em&gt;Python 3.x&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;You can also find the IDLE program icon by using the Windows search from the Start menu and typing in &lt;em&gt;IDLE&lt;/em&gt;.
Click on the icon to start the program.&lt;/p&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-tab-1&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;p&gt;IDLE is available with the Python distribution but may not have been installed by default. To find out whether it’s installed, open a terminal window.&lt;/p&gt;
&lt;p&gt;In the terminal window, type &lt;code&gt;idle3&lt;/code&gt; and press &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt;.
If you get an error telling you that the command wasn’t found, then IDLE isn’t installed and you’ll need to install it.&lt;/p&gt;
&lt;p&gt;The method for installing apps varies from one Linux distribution to the next. For example, with Ubuntu Linux, you can install IDLE using the package manager &lt;code&gt;apt&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;sudo&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;apt&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;idle3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Many Linux distributions have GUI-based application managers that you can use to install apps as well.&lt;/p&gt;
&lt;p&gt;Follow whatever procedure is appropriate for your distribution to install IDLE. Then, type &lt;code&gt;idle3&lt;/code&gt; in a terminal window and press &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt; to run it. Your installation procedure may have also set up a program icon on the desktop that you can alternatively click to start IDLE.&lt;/p&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;macos-tab-1&quot; class=&quot;tab-pane fade &quot; id=&quot;macos-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;p&gt;Open Spotlight Search and search for &lt;em&gt;IDLE&lt;/em&gt;. Alternatively, you can open a terminal window, type &lt;code&gt;idle3&lt;/code&gt; and press &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once you’ve started IDLE successfully, you should see a window titled &lt;em&gt;IDLE Shell 3.x.x&lt;/em&gt;, where 3.x.x corresponds to your version of Python:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/idle-blank.63e93ca86755.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block border &quot; src=&quot;https://files.realpython.com/media/idle-blank.63e93ca86755.png&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/idle-blank.63e93ca86755.png 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/idle-blank.63e93ca86755.png 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/idle-blank.63e93ca86755.png 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/idle-blank.63e93ca86755.png 1920w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Interactive Python interpreter session in IDLE 3.13&quot; data-asset=&quot;6026&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;The window that you’re seeing is the IDLE shell, which is an &lt;strong&gt;interactive interpreter&lt;/strong&gt; that IDLE opens by default.&lt;/p&gt;
&lt;h2 id=&quot;get-to-know-the-python-idle-shell&quot;&gt;Get to Know the Python IDLE Shell&lt;a class=&quot;headerlink&quot; href=&quot;#get-to-know-the-python-idle-shell&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you open IDLE, the &lt;strong&gt;shell&lt;/strong&gt; is the first thing that you see. The shell is the default mode of operation for Python IDLE. It’s a blank Python interpreter window, which you can use  to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; immediately.&lt;/p&gt;
&lt;h3 id=&quot;understanding-the-interactive-interpreter&quot;&gt;Understanding the Interactive Interpreter&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-the-interactive-interpreter&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The interactive interpreter is a basic &lt;a href=&quot;/ref/glossary/repl/&quot; class=&quot;ref-link&quot;&gt;Read-Eval-Print Loop (REPL)&lt;/a&gt;. It reads a Python statement, evaluates the result of that statement, and then prints the result on the screen. Then, it loops back to read the next statement.&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; For a full guide to the standard Python REPL, check out &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;The Python Standard REPL: Try Out Code and Ideas Quickly&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The IDLE shell is an excellent place to experiment with small code snippets and test short lines of code.&lt;/p&gt;
&lt;h3 id=&quot;interacting-with-the-idle-shell&quot;&gt;Interacting With the IDLE Shell&lt;a class=&quot;headerlink&quot; href=&quot;#interacting-with-the-idle-shell&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you launch Python’s IDLE, it will immediately start a Python shell for you. Go ahead and write some Python code in the shell:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/hello-world-idle.55208a57b4b6.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block border &quot; src=&quot;https://files.realpython.com/media/hello-world-idle.55208a57b4b6.png&quot; width=&quot;1920&quot; height=&quot;794&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/hello-world-idle.55208a57b4b6.png 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/hello-world-idle.55208a57b4b6.png 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/hello-world-idle.55208a57b4b6.png 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/hello-world-idle.55208a57b4b6.png 1920w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Hello World program shown in the IDLE python interpreter&quot; data-asset=&quot;1191&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Here, you used &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; to output the string &lt;code&gt;&quot;Hello, from IDLE!&quot;&lt;/code&gt; to your screen. This is the most basic way to interact with Python IDLE. You type in commands one at a time and Python responds with the result of each command.&lt;/p&gt;
&lt;p&gt;Next, take a look at the menu bar. You’ll see a few options for using the shell:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-idle/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-idle/ »&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>MySQL Databases and Python</title>
      <id>https://realpython.com/courses/mysql-databases-python/</id>
      <link href="https://realpython.com/courses/mysql-databases-python/"/>
      <updated>2025-04-22T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to connect your Python application with a MySQL database. You&#x27;ll design a movie rating system and perform some common queries on it. You&#x27;ll also see best practices and tips to prevent SQL injection attacks.</summary>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://mysql.com/&quot;&gt;MySQL&lt;/a&gt; is one of the most popular &lt;a href=&quot;https://en.wikipedia.org/wiki/Database#Database_management_system&quot;&gt;database management systems (DBMSs)&lt;/a&gt; on the market today. It ranked second only to the &lt;a href=&quot;https://docs.oracle.com/cd/E11882_01/server.112/e40540/intro.htm&quot;&gt;Oracle DBMS&lt;/a&gt; in this year&amp;rsquo;s &lt;a href=&quot;https://db-engines.com/en/ranking&quot;&gt;DB-Engines Ranking&lt;/a&gt;. As most software applications need to interact with data in some form, programming languages like Python provide tools for storing and accessing these data sources.&lt;/p&gt;
&lt;p&gt;Using the techniques discussed in this video course, you&amp;rsquo;ll be able to efficiently integrate a MySQL database with a Python application. You&amp;rsquo;ll develop a small MySQL database for a movie rating system and learn how to query it directly from your Python code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll be able to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Identify unique features of &lt;strong&gt;MySQL&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connect your application&lt;/strong&gt; to a MySQL database&lt;/li&gt;
&lt;li&gt;Query the database to &lt;strong&gt;fetch required data&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Handle exceptions&lt;/strong&gt; that occur while accessing the database&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;best practices&lt;/strong&gt; while building database applications&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Shallow vs Deep Copying of Python Objects</title>
      <id>https://realpython.com/python-copy/</id>
      <link href="https://realpython.com/python-copy/"/>
      <updated>2025-04-21T14:00:00+00:00</updated>
      <summary>What&#x27;s the difference between a shallow copy and a deep copy of a Python object? Learn how to clone arbitrary objects in Python, including your own custom classes.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s assignment statements don’t copy objects as they do in some other programming languages. Instead, they create bindings between your variable names and objects. For immutable objects, this distinction usually doesn’t matter. However, when you work with mutable objects or containers of mutable items, you may need to create explicit copies or “clones” of these objects.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shallow copying&lt;/strong&gt; creates a new object but references the same nested objects, leading to shared changes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deep copying&lt;/strong&gt; recursively duplicates all objects, ensuring full independence from the original.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python’s &lt;code&gt;copy&lt;/code&gt; module&lt;/strong&gt; provides the &lt;code&gt;copy()&lt;/code&gt; function for shallow copies and &lt;code&gt;deepcopy()&lt;/code&gt; for deep copies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Custom classes&lt;/strong&gt; can implement &lt;code&gt;.__copy__()&lt;/code&gt; and &lt;code&gt;.__deepcopy__()&lt;/code&gt; for specific copying behavior.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assignment in Python&lt;/strong&gt; binds variable names to objects without copying, unlike some lower-level languages.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Explore the nuances of copying objects in Python and learn how to apply these techniques to manage mutable data structures effectively.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-copy-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-copy-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code &lt;/a&gt; that you’ll use to learn about shallow vs deep copying in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Shallow vs Deep Copying of Python Objects” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-copy/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #e5c5ac;&quot; alt=&quot;Shallow vs Deep Copying of Python Objects&quot; src=&quot;https://files.realpython.com/media/Shallow-vs-Deep-Copying-of-Python-Objects_Watermarked.e6471b4627f8.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Shallow-vs-Deep-Copying-of-Python-Objects_Watermarked.e6471b4627f8.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Shallow-vs-Deep-Copying-of-Python-Objects_Watermarked.e6471b4627f8.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Shallow-vs-Deep-Copying-of-Python-Objects_Watermarked.e6471b4627f8.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Shallow-vs-Deep-Copying-of-Python-Objects_Watermarked.e6471b4627f8.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-copy/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Shallow vs Deep Copying of Python Objects&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python&#x27;s copy module, which provides tools for creating shallow and deep copies of objects. This knowledge is crucial for managing complex, mutable data structures safely and effectively.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;getting-the-big-picture-of-object-copying&quot;&gt;Getting the Big Picture of Object Copying&lt;a class=&quot;headerlink&quot; href=&quot;#getting-the-big-picture-of-object-copying&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Copying an object means creating its &lt;strong&gt;exact duplicate&lt;/strong&gt; in memory. While there are many good reasons for doing so, at the end of the day, it allows you to &lt;em&gt;modify&lt;/em&gt; the cloned objects independently of each other.&lt;/p&gt;
&lt;p&gt;For example, a &lt;a href=&quot;https://realpython.com/python-getter-setter/&quot;&gt;getter method&lt;/a&gt; may return sensitive information like the balance of someone’s bank account. To prevent unauthorized modifications of the bank account’s state, whether accidental or intentional, you’ll typically return a copy of the original data as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Defensive_programming&quot;&gt;defensive programming&lt;/a&gt; measure. That way, you’ll have two separate objects safely representing the same piece of information.&lt;/p&gt;
&lt;p&gt;Sometimes, you may need to work with multiple snapshots of the same data. In &lt;a href=&quot;https://en.wikipedia.org/wiki/3D_computer_graphics&quot;&gt;3D computer graphics&lt;/a&gt;, transformations like rotation and scaling rely on &lt;a href=&quot;https://en.wikipedia.org/wiki/Matrix_multiplication&quot;&gt;matrix multiplication&lt;/a&gt; to update a model’s vertices. Rather than permanently changing the original model, you can duplicate its vertices and apply transformations to the copy. This will allow you to animate the model in a non-destructive way.&lt;/p&gt;
&lt;p&gt;The following section provides an overview of the fundamental concepts and challenges associated with object copying in general. If you’d like to jump straight to &lt;a href=&quot;#understanding-shallow-and-deep-copying&quot;&gt;copying objects in Python&lt;/a&gt;, then feel free to skip ahead.&lt;/p&gt;
&lt;h3 id=&quot;scalar-vs-composite-types&quot;&gt;Scalar vs Composite Types&lt;a class=&quot;headerlink&quot; href=&quot;#scalar-vs-composite-types&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In programming, objects can be classified into two broad categories of data types:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Scalar&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Composite&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Scalar_processor#Scalar_data_type&quot;&gt;Scalar data types&lt;/a&gt; represent simple, indivisible values that can’t be decomposed into smaller parts, much like atoms were once thought to be. Examples of scalars in Python include &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-datetime/&quot;&gt;dates&lt;/a&gt;, and &lt;a href=&quot;https://docs.python.org/3/library/uuid.html&quot;&gt;UUID-type identifiers&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&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;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid4&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&lt;/span&gt; &lt;span class=&quot;o&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;mf&quot;&gt;3.14&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;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dates&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1991&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;20&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;ids&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Each of these objects holds a single value representing a basic unit of data. By combining these fundamental building blocks, you can create more complex data structures.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Composite_data_type&quot;&gt;Composite data types&lt;/a&gt;, on the other hand, are containers made up of other elements. Some of them are merely collections of scalar values, while others contain other composites or both, forming a complex hierarchy of objects:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;array&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;audio_frames&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;h&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;2644&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2814&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3001&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;audio_data&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;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;PCM&quot;&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;44100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&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;... &lt;/span&gt;        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;15975&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;28928&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;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;86&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15858&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;mi&quot;&gt;31999&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&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;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this case, the &lt;code&gt;&quot;h&quot;&lt;/code&gt; argument in the &lt;a href=&quot;https://docs.python.org/3/library/array.html&quot;&gt;&lt;code&gt;array.array()&lt;/code&gt;&lt;/a&gt; call specifies that the array will store numbers as two-byte signed integers. As you can see, a &lt;a href=&quot;https://realpython.com/python-array/&quot;&gt;Python array&lt;/a&gt; aggregates scalar numbers into a flat sequence, whereas a &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list and tuple&lt;/a&gt; can contain deeply nested structures arranged in a particular way.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Python types can sometimes fall into a gray area. For example, strings have a dual nature, as they’re technically sequences of characters. At the same time, they behave like scalars in specific contexts because they don’t allow element-wise operations—you must treat them as a whole.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;These two categories of data types are closely related to the concept of &lt;strong&gt;object mutability&lt;/strong&gt;, which you’ll learn more about now.&lt;/p&gt;
&lt;h3 id=&quot;mutable-vs-immutable-objects&quot;&gt;Mutable vs Immutable Objects&lt;a class=&quot;headerlink&quot; href=&quot;#mutable-vs-immutable-objects&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In high-level programming languages like &lt;a href=&quot;https://realpython.com/java-vs-python/&quot;&gt;Java&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-vs-javascript/&quot;&gt;JavaScript&lt;/a&gt;, &lt;strong&gt;scalar types&lt;/strong&gt; typically represent read-only values that can’t change over time. Such objects don’t allow &lt;a href=&quot;https://en.wikipedia.org/wiki/In-place_algorithm&quot;&gt;in-place&lt;/a&gt; state mutation during their lifetime. So, if you want to modify a scalar value, then your only option is to disregard it and create another instance with a different value. In contrast, &lt;strong&gt;composite types&lt;/strong&gt; can be either &lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/&quot;&gt;mutable or immutable&lt;/a&gt;, depending on their implementation.&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; Immutable types have several advantages, including &lt;a href=&quot;https://realpython.com/python-thread-lock/&quot;&gt;thread safety&lt;/a&gt; and improved &lt;a href=&quot;https://en.wikipedia.org/wiki/Memory_footprint&quot;&gt;memory efficiency&lt;/a&gt;, as they let you reuse objects without copying. On the other hand, when &lt;a href=&quot;https://en.wikipedia.org/wiki/Algorithmic_efficiency&quot;&gt;performance&lt;/a&gt; is vital, mutable types can reduce the overhead associated with object creation, especially when you tend to modify your objects frequently.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-copy/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-copy/ »&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>Quiz: Shallow vs Deep Copying of Python Objects</title>
      <id>https://realpython.com/quizzes/python-copy/</id>
      <link href="https://realpython.com/quizzes/python-copy/"/>
      <updated>2025-04-21T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python&#x27;s copy module, which provides tools for creating shallow and deep copies of objects. This knowledge is crucial for managing complex, mutable data structures safely and effectively.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/python-copy/&quot;&gt;Shallow vs Deep Copying of Python Objects&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the concepts of shallow and deep copying, and how they affect mutable objects in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #247: Exploring DuckDB &amp; Comparing Python Expressions vs Statements</title>
      <id>https://realpython.com/podcasts/rpp/247/</id>
      <link href="https://realpython.com/podcasts/rpp/247/"/>
      <updated>2025-04-18T12:00:00+00:00</updated>
      <summary>Are you looking for a fast database that can handle large datasets in Python? What&#x27;s the difference between a Python expression and a statement? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Are you looking for a fast database that can handle large datasets in Python? What&#x27;s the difference between a Python expression and a statement? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Exit Loops Early With the Python Break Keyword</title>
      <id>https://realpython.com/python-break/</id>
      <link href="https://realpython.com/python-break/"/>
      <updated>2025-04-16T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll explore various ways to use Python&#x27;s break statement to exit a loop early. Through practical examples, such as a student test score analysis tool and a number-guessing game, you&#x27;ll see how the break statement can improve the efficiency and effectiveness of your code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In Python, the &lt;a href=&quot;/ref/keywords/break/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;break&lt;/code&gt; statement&lt;/a&gt; lets you exit a loop prematurely, transferring control to the code that follows the loop. This tutorial guides you through using &lt;code&gt;break&lt;/code&gt; in both &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; loops. You’ll also briefly explore the &lt;code&gt;continue&lt;/code&gt; keyword, which complements &lt;code&gt;break&lt;/code&gt; by skipping the current loop iteration.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A &lt;code&gt;break&lt;/code&gt; in Python&lt;/strong&gt; is a keyword that lets you exit a loop immediately, stopping further iterations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Using &lt;code&gt;break&lt;/code&gt; outside of loops&lt;/strong&gt; doesn’t make sense because it’s specifically designed to exit loops early.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The &lt;code&gt;break&lt;/code&gt; doesn’t exit all loops&lt;/strong&gt;, only the innermost loop that contains it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To explore the use of &lt;code&gt;break&lt;/code&gt; in Python, you’ll determine if a student needs tutoring based on the number of failed test scores. Then, you’ll print out a given number of test scores and calculate how many students failed at least one test.&lt;/p&gt;
&lt;p&gt;You’ll also take a brief detour from this main scenario to examine how you can use &lt;code&gt;break&lt;/code&gt; statements to accept and process user input, using a number-guessing game.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-break-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-break-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code &lt;/a&gt; that shows you how to exit loops early with the Python break keyword.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “How to Exit Loops Early With the Python Break Keyword” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-break/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #abe0e6;&quot; alt=&quot;How to Exit Loops Early With the Python Break Keyword&quot; src=&quot;https://files.realpython.com/media/Exit-Loops-Early-With-Pythons-Break-Keyword_Watermarked.3d61a543d1f4.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Exit-Loops-Early-With-Pythons-Break-Keyword_Watermarked.3d61a543d1f4.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Exit-Loops-Early-With-Pythons-Break-Keyword_Watermarked.3d61a543d1f4.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Exit-Loops-Early-With-Pythons-Break-Keyword_Watermarked.3d61a543d1f4.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Exit-Loops-Early-With-Pythons-Break-Keyword_Watermarked.3d61a543d1f4.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-break/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Exit Loops Early With the Python Break Keyword&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of the Python break statement. This keyword allows you to exit a loop prematurely, transferring control to the code that follows the loop.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;introducing-the-break-statement&quot;&gt;Introducing the &lt;code&gt;break&lt;/code&gt; Statement&lt;a class=&quot;headerlink&quot; href=&quot;#introducing-the-break-statement&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before proceeding to the main examples, here’s a basic explanation of what the &lt;code&gt;break&lt;/code&gt; statement is and what it does. It’s a Python keyword that, when used in a loop, immediately exits the loop and transfers control to the code that would normally run after the loop’s standard conclusion.&lt;/p&gt;
&lt;p&gt;You can see the basics of the &lt;code&gt;break&lt;/code&gt; statement in a simple example. The following code demonstrates a loop that prints numbers within a range until the next number is greater than 5:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&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;10&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;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;break&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;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This short code example consists of a &lt;a href=&quot;/ref/keywords/for/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/a&gt; that iterates through a range of numbers from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;9&lt;/code&gt;. It &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;prints&lt;/a&gt; out each number, but when the next number is &lt;code&gt;5&lt;/code&gt;, a &lt;code&gt;break&lt;/code&gt; statement terminates the loop early. So, this code will print the numbers from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt;, and then the loop will end.&lt;/p&gt;
&lt;p&gt;As &lt;code&gt;break&lt;/code&gt; statements end loops early, it wouldn’t make sense for you to use them in any context that doesn’t involve a loop. In fact, Python will raise a &lt;a href=&quot;https://realpython.com/invalid-syntax-python/&quot;&gt;&lt;code&gt;SyntaxError&lt;/code&gt;&lt;/a&gt; if you try to use a &lt;code&gt;break&lt;/code&gt; statement outside of a loop.&lt;/p&gt;
&lt;p&gt;A key benefit of using &lt;code&gt;break&lt;/code&gt; statements is that you can prevent unnecessary loop iterations by exiting early when appropriate. You’ll see this in action in the next section.&lt;/p&gt;
&lt;h2 id=&quot;breaking-out-of-a-loop-with-a-set-number-of-iterations&quot;&gt;Breaking Out of a Loop With a Set Number of Iterations&lt;a class=&quot;headerlink&quot; href=&quot;#breaking-out-of-a-loop-with-a-set-number-of-iterations&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine you’re a teacher who evaluates the scores of your students. Based on the scores, you want to determine how many tests each student has failed. The following example demonstrates how you might accomplish this task using a &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/a&gt; to iterate through the students’ test scores:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scores&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;90&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;85&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;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_failed_scores&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;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pass_score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&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;score&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scores&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;score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pass_score&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;num_failed_scores&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;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;Number of failed tests: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_failed_scores&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Number of failed tests: 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You start with a list of scores for one student. Before the loop runs, you set a few variables. The variable &lt;code&gt;num_failed_scores&lt;/code&gt; is set at &lt;code&gt;0&lt;/code&gt;, because you haven’t yet found any failing scores. &lt;code&gt;pass_score&lt;/code&gt;, the variable that stores the threshold for passing a test, is set at &lt;code&gt;60&lt;/code&gt;, so any score less than that is considered a failed test.&lt;/p&gt;
&lt;p&gt;As the &lt;code&gt;for&lt;/code&gt; loop begins, it will run as many times as there are scores in the list, iterating over each score. If the score is less than the failing score threshold, it increments the &lt;code&gt;num_failed_scores&lt;/code&gt; variable by &lt;code&gt;1&lt;/code&gt;. Finally, you output the number of tests that the student failed.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-break/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-break/ »&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>Quiz: How to Exit Loops Early With the Python Break Keyword</title>
      <id>https://realpython.com/quizzes/python-break/</id>
      <link href="https://realpython.com/quizzes/python-break/"/>
      <updated>2025-04-16T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of the Python break statement. This keyword allows you to exit a loop prematurely, transferring control to the code that follows the loop.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of the Python &lt;a href=&quot;https://realpython.com/python-break/&quot;&gt;&lt;code&gt;break&lt;/code&gt; statement&lt;/a&gt;.
This keyword allows you to exit a loop prematurely, transferring control to the code that follows the loop.&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>Creating a Python Dice Roll Application</title>
      <id>https://realpython.com/courses/creating-dice-roll-application/</id>
      <link href="https://realpython.com/courses/creating-dice-roll-application/"/>
      <updated>2025-04-15T14:00:00+00:00</updated>
      <summary>In this step-by-step video course, you&#x27;ll build a dice-rolling simulator app with a minimal text-based user interface using Python. The app will simulate the rolling of up to six dice. Each individual die will have six sides.</summary>
      <content type="html">
        &lt;p&gt;In this video course, you&amp;rsquo;ll learn how to create a Python dice roll simulator. The course guides you through building a text-based user interface (TUI) application that simulates rolling dice using Python&amp;rsquo;s &lt;code&gt;random&lt;/code&gt; module. You&amp;rsquo;ll learn to gather and validate user input, use &lt;code&gt;random.randint()&lt;/code&gt; for dice rolling, and display results with ASCII art.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To simulate &lt;strong&gt;dice-rolling&lt;/strong&gt; events, you can use &lt;strong&gt;&lt;code&gt;random.randint()&lt;/code&gt;&lt;/strong&gt; .&lt;/li&gt;
&lt;li&gt;To get the &lt;strong&gt;user&amp;rsquo;s input&lt;/strong&gt;, you use the built-in &lt;strong&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/strong&gt; function.&lt;/li&gt;
&lt;li&gt;To display dice in Python, you generate &lt;strong&gt;ASCII art representations&lt;/strong&gt; of dice faces and use &lt;strong&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To manipulate &lt;strong&gt;strings&lt;/strong&gt;, you use methods such as &lt;strong&gt;&lt;code&gt;.center()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;.join()&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Namespaces in Python</title>
      <id>https://realpython.com/python-namespace/</id>
      <link href="https://realpython.com/python-namespace/"/>
      <updated>2025-04-14T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about Python namespaces, the structures that store and organize the symbolic names during the execution of a Python program. You&#x27;ll learn when namespaces are created, how they&#x27;re implemented, and how they support variable scope.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;A Python &lt;strong&gt;namespace&lt;/strong&gt; is a mapping from names to objects. It works like a dictionary where keys are object names and values are the objects themselves. Namespaces organize variables and functions in a dedicated space, allowing you to use multiple instances of the same name without conflict, as long as they’re in different namespaces.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll explore the different types of namespaces in Python, including the built-in, global, local, and enclosing namespaces. You’ll also learn how they define the scope of names and influence name resolution in Python programs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Python &lt;strong&gt;namespaces&lt;/strong&gt; serve as containers that &lt;strong&gt;map names to objects&lt;/strong&gt;, allowing for organized access and management of variables, functions, classes, and objects in general.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Namespace and scope&lt;/strong&gt; differ in that a namespace maps names to objects, while a scope is the &lt;strong&gt;region of code&lt;/strong&gt; where you can access a name.&lt;/li&gt;
&lt;li&gt;Python &lt;strong&gt;implements&lt;/strong&gt; most namespaces using &lt;strong&gt;dictionaries&lt;/strong&gt;, where each namespace’s lifecycle is tied to the execution context, such as global or local scopes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding how namespaces work will improve your ability to manage and organize code efficiently in Python programs, helping to prevent name conflicts and other issues. To get the most out of this tutorial, you should be familiar with Python &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;. Knowledge of &lt;a href=&quot;https://realpython.com/inner-functions-what-are-they-good-for/&quot;&gt;inner functions&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-closure/&quot;&gt;closures&lt;/a&gt; will also be a plus.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-namespaces-scope-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-namespaces-scope-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code &lt;/a&gt; that you’ll use to learn about namespaces and scope in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Namespaces in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-namespace/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ffc973;&quot; alt=&quot;Namespaces and Scopes in Python&quot; src=&quot;https://files.realpython.com/media/UPDATE-Namespaces-and-Scope-in-Python_Watermarked.0597679893f1.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/UPDATE-Namespaces-and-Scope-in-Python_Watermarked.0597679893f1.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/UPDATE-Namespaces-and-Scope-in-Python_Watermarked.0597679893f1.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/UPDATE-Namespaces-and-Scope-in-Python_Watermarked.0597679893f1.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/UPDATE-Namespaces-and-Scope-in-Python_Watermarked.0597679893f1.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-namespace/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Namespaces in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python namespaces. These concepts are crucial for organizing the symbolic names assigned to objects in a Python program and ensuring they don&#x27;t interfere with one another.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;getting-to-know-namespaces-in-python&quot;&gt;Getting to Know Namespaces in Python&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-namespaces-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&quot;/ref/glossary/namespace/&quot; class=&quot;ref-link&quot;&gt;namespace&lt;/a&gt; is a container that holds the currently defined symbolic names and the objects each name references. You can think of a namespace as a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt;, in which the keys are object names and the values are the objects themselves. Each key-value pair maps a name to its corresponding object.&lt;/p&gt;
&lt;p&gt;Namespaces let you use the same name in different contexts without collisions. It’s like giving everything its own little room in a well-organized house. They allow Python to keep things organized, prevent naming conflicts, support the concept of &lt;a href=&quot;#understanding-the-scope-of-names&quot;&gt;scope&lt;/a&gt;, and enforce modularity.&lt;/p&gt;
&lt;p&gt;Namespaces are so crucial in Python that they were immortalized in &lt;a href=&quot;https://realpython.com/zen-of-python/&quot;&gt;The Zen of Python&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Namespaces are one honking great idea—let’s do more of those!&lt;/p&gt;
&lt;p&gt;— &lt;em&gt;Tim Peters&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As Tim Peters suggests, namespaces aren’t just great. They’re &lt;em&gt;honking&lt;/em&gt; great, and Python uses them extensively. Depending on how you structure your code, a Python program can have up to four different types of namespaces:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Built-In&lt;/li&gt;
&lt;li&gt;Global&lt;/li&gt;
&lt;li&gt;Local&lt;/li&gt;
&lt;li&gt;Enclosing or nonlocal&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These namespaces have differing lifetimes. As Python executes a program, it creates namespaces as necessary and removes them when it no longer needs them. Typically, many namespaces will exist at any given time.&lt;/p&gt;
&lt;p&gt;The Python global, local, and nonlocal namespaces are implemented as dictionaries. In contrast, the built-in namespace isn’t a dictionary but a module called &lt;code&gt;builtins&lt;/code&gt;. This module acts as the container for the built-in namespace.&lt;/p&gt;
&lt;p&gt;In the following sections, you’ll learn about these four namespaces and what their content and behavior are.&lt;/p&gt;
&lt;h3 id=&quot;the-built-in-namespace&quot;&gt;The Built-in Namespace&lt;a class=&quot;headerlink&quot; href=&quot;#the-built-in-namespace&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;built-in namespace&lt;/strong&gt; contains the names of all of Python’s built-in objects. This namespace is available while the Python &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt; is running. So, you can access the names that live in this namespace at any time in your code without explicitly importing them.&lt;/p&gt;
&lt;p&gt;You can list the objects in the built-in namespace with the &lt;a href=&quot;/ref/builtin-functions/dir/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;dir()&lt;/code&gt;&lt;/a&gt; function using the &lt;code&gt;__builtins__&lt;/code&gt; object as an argument:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__builtins__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;ArithmeticError&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;AssertionError&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;AttributeError&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;BaseException&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    ...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;super&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;tuple&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;type&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;vars&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;zip&#x27;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You may recognize some objects here, such as &lt;a href=&quot;https://realpython.com/python-built-in-exceptions/&quot;&gt;built-in exceptions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-data-types/#built-in-functions&quot;&gt;built-in functions&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/ref/builtin-types/&quot;&gt;built-in data types&lt;/a&gt;. Python creates the built-in namespace when it starts and keeps it active until the interpreter terminates.&lt;/p&gt;
&lt;h3 id=&quot;the-global-namespace&quot;&gt;The Global Namespace&lt;a class=&quot;headerlink&quot; href=&quot;#the-global-namespace&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;global namespace&lt;/strong&gt; contains the names defined at the module level. Python creates a main global namespace when the main program’s body starts. This namespace remains in existence until the interpreter terminates.&lt;/p&gt;
&lt;p&gt;Additionally, each module has its own global namespace. The interpreter creates a global namespace for any module that your program loads with the &lt;a href=&quot;https://realpython.com/absolute-vs-relative-python-imports/&quot;&gt;&lt;code&gt;import&lt;/code&gt;&lt;/a&gt; statement. For further reading on main functions and modules in Python, see the following resources:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-namespace/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-namespace/ »&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>Quiz: Namespaces in Python</title>
      <id>https://realpython.com/quizzes/python-namespace/</id>
      <link href="https://realpython.com/quizzes/python-namespace/"/>
      <updated>2025-04-14T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python namespaces. These concepts are crucial for organizing the symbolic names assigned to objects in a Python program and ensuring they don&#x27;t interfere with one another.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/python-namespace/&quot;&gt;Namespaces in Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll revisit how Python organizes symbolic names and objects in namespaces, when Python creates a new namespace, how namespaces are implemented, and how variable scope determines symbolic name visibility.&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 #246: Learning Intermediate Python With a Deep Dive Course</title>
      <id>https://realpython.com/podcasts/rpp/246/</id>
      <link href="https://realpython.com/podcasts/rpp/246/"/>
      <updated>2025-04-11T12:00:00+00:00</updated>
      <summary>Do you want to learn deeper concepts in Python? Would the accountability of scheduled group classes help you get past the basics? This week, five Real Python Intermediate Deep Dive workshop members discuss their experiences.</summary>
      <content type="html">
        &lt;p&gt;Do you want to learn deeper concepts in Python? Would the accountability of scheduled group classes help you get past the basics? This week, five Real Python Intermediate Deep Dive workshop members discuss their experiences.&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 Python&#x27;s .__dict__ to Work With Attributes</title>
      <id>https://realpython.com/python-dict-attribute/</id>
      <link href="https://realpython.com/python-dict-attribute/"/>
      <updated>2025-04-09T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll dive deeper into the .__dict__ attribute in Python objects. This attribute is a dictionary-like object that holds writable class or instance attributes. It allows you to manage attributes at a low level, making your classes flexible and efficient.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s &lt;code&gt;.__dict__&lt;/code&gt; is a special attribute in classes and instances that acts as a namespace, mapping attribute names to their corresponding values. You can use &lt;code&gt;.__dict__&lt;/code&gt; to inspect, modify, add, or delete attributes dynamically, which makes it a versatile tool for metaprogramming and debugging.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn about using &lt;code&gt;.__dict__&lt;/code&gt; in various contexts, including classes, instances, and functions. You’ll also explore its role in inheritance with practical examples and comparisons to other tools for manipulating attributes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;.__dict__&lt;/code&gt;&lt;/strong&gt; holds an object’s &lt;strong&gt;writable attributes&lt;/strong&gt;, allowing for dynamic manipulation and introspection.&lt;/li&gt;
&lt;li&gt;Both &lt;strong&gt;&lt;code&gt;vars()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;.__dict__&lt;/code&gt;&lt;/strong&gt; let you &lt;strong&gt;inspect&lt;/strong&gt; an object’s attributes. The &lt;code&gt;.__dict__&lt;/code&gt; attribute gives you direct access to the object’s namespace, while the &lt;code&gt;vars()&lt;/code&gt; function returns the object’s &lt;code&gt;.__dict__&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Common use cases of &lt;code&gt;.__dict__&lt;/code&gt; include &lt;strong&gt;dynamic attribute management&lt;/strong&gt;, &lt;strong&gt;introspection&lt;/strong&gt;, &lt;strong&gt;serialization&lt;/strong&gt;, and &lt;strong&gt;debugging&lt;/strong&gt; in Python applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While this tutorial provides detailed insights into using &lt;code&gt;.__dict__&lt;/code&gt; effectively, having a solid understanding of Python &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt; and how to use them in your code will help you get the most out of it.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-dict-attribute-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-dict-attribute-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code &lt;/a&gt; you’ll use to learn about using Python’s &lt;code&gt;.__dict__&lt;/code&gt; to work with attributes.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Using Python&#x27;s .__dict__ to Work With Attributes” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-dict-attribute/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #e5c6aa;&quot; alt=&quot;Using Python&#x27;s .__dict__ to Work With Attributes&quot; src=&quot;https://files.realpython.com/media/Using-Pythons-.__dict__-to-Inspect-Object-Attributes_Watermarked.e648f20c0563.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Using-Pythons-.__dict__-to-Inspect-Object-Attributes_Watermarked.e648f20c0563.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Using-Pythons-.__dict__-to-Inspect-Object-Attributes_Watermarked.e648f20c0563.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Using-Pythons-.__dict__-to-Inspect-Object-Attributes_Watermarked.e648f20c0563.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Using-Pythons-.__dict__-to-Inspect-Object-Attributes_Watermarked.e648f20c0563.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-dict-attribute/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Using Python&#x27;s .__dict__ to Work With Attributes&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python&#x27;s .__dict__ attribute and its usage in classes, instances, and functions. Acting as a namespace, this attribute maps attribute names to their corresponding values and serves as a versatile tool for metaprogramming and debugging.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;getting-to-know-the-__dict__-attribute-in-python&quot;&gt;Getting to Know the &lt;code&gt;.__dict__&lt;/code&gt; Attribute in Python&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-the-__dict__-attribute-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python supports the &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming (OOP)&lt;/a&gt; paradigm through &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt; that &lt;span data-invalid-ref=&quot;glossary/encapsulation&quot;&gt;encapsulate&lt;/span&gt; data (attributes) and behaviors (methods) in a single entity. Under the hood, Python takes advantage of dictionaries to handle these attributes and methods.&lt;/p&gt;
&lt;p&gt;Why dictionaries? Because they’re implemented as hash tables, which map keys to values, making lookup operations fast and efficient.&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; To learn more about using Python dictionaries, check out the following resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;Dictionaries in Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/iterate-through-dictionary-python/&quot;&gt;How to Iterate Through a Dictionary in Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/sort-python-dictionary/&quot;&gt;Sorting a Python Dictionary: Values, Keys, and More&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-dictionary-comprehension/&quot;&gt;Python Dictionary Comprehensions: How and When to Use Them&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;Generally, Python uses a special dictionary called &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__dict__&quot;&gt;&lt;code&gt;.__dict__&lt;/code&gt;&lt;/a&gt; to maintain references to writable attributes and methods in a Python class or instance. In practice, the &lt;code&gt;.__dict__&lt;/code&gt; attribute is a &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;namespace&lt;/a&gt; that maps attribute names to values and method names to method objects.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.__dict__&lt;/code&gt; attribute is fundamental to Python’s &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html&quot;&gt;data model&lt;/a&gt;. The interpreter recognizes and uses it internally to process classes and objects. It enables dynamic attribute access, addition, removal, and manipulation. You’ll learn how to do these operations in a moment. But first, you’ll look at the differences between the class &lt;code&gt;.__dict__&lt;/code&gt; and the instance &lt;code&gt;.__dict__&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;the-__dict__-class-attribute&quot;&gt;The &lt;code&gt;.__dict__&lt;/code&gt; Class Attribute&lt;a class=&quot;headerlink&quot; href=&quot;#the-__dict__-class-attribute&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To start learning about &lt;code&gt;.__dict__&lt;/code&gt; in a Python class, you’ll use the following demo class, which has attributes and methods:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    &lt;span class=&quot;mr-2&quot; aria-label=&quot;Filename&quot;&gt;&lt;code style=&quot;color: inherit; background: inherit;&quot;&gt;demo.py&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DemoClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;class_attr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;This is a class attribute&quot;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;fm&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instance_attr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;This is an instance attribute&quot;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;This is a method&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this class, you have a class attribute, two methods, and an &lt;a href=&quot;https://realpython.com/python-classes/#instance-attributes&quot;&gt;instance attribute&lt;/a&gt;. Now, start a Python &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt; session and run the following code:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;demo&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DemoClass&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DemoClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;vm&quot;&gt;__dict__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__module__&#x27;: &#x27;demo&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__firstlineno__&#x27;: 1,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;class_attr&#x27;: &#x27;This is a class attribute&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__init__&#x27;: &amp;lt;function DemoClass.__init__ at 0x102bcd120&amp;gt;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;method&#x27;: &amp;lt;function DemoClass.method at 0x102bcd260&amp;gt;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__static_attributes__&#x27;: (&#x27;instance_attr&#x27;,),&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__dict__&#x27;: &amp;lt;attribute &#x27;__dict__&#x27; of &#x27;DemoClass&#x27; objects&amp;gt;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__weakref__&#x27;: &amp;lt;attribute &#x27;__weakref__&#x27; of &#x27;DemoClass&#x27; objects&amp;gt;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__doc__&#x27;: None&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The call to &lt;code&gt;print()&lt;/code&gt; displays a dictionary that maps names to objects. First, you have the &lt;code&gt;&#x27;__module__&#x27;&lt;/code&gt; key, which maps to a special attribute that specifies where the class is defined. In this case, the class lives in the &lt;code&gt;demo&lt;/code&gt; module. Then, you have the &lt;code&gt;&#x27;__firstlineno__&#x27;&lt;/code&gt; key, which holds the line number of the first line of the class definition, including decorators. Next, you have the &lt;code&gt;&#x27;class_attr&#x27;&lt;/code&gt; key and its corresponding value.&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; When you access the &lt;code&gt;.__dict__&lt;/code&gt; attribute on a class, you get a &lt;code&gt;mappingproxy&lt;/code&gt; object. This type of object creates a read-only &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects&quot;&gt;view&lt;/a&gt; of a dictionary.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;&#x27;__init__&#x27;&lt;/code&gt; and &lt;code&gt;&#x27;method&#x27;&lt;/code&gt; keys map to the corresponding method objects &lt;a href=&quot;https://realpython.com/python-class-constructor/#object-initialization-with-__init__&quot;&gt;&lt;code&gt;.__init__()&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;.method()&lt;/code&gt;. Next, you have a key called &lt;code&gt;&#x27;__dict__&#x27;&lt;/code&gt; that maps to the attribute &lt;code&gt;.__dict__&lt;/code&gt; of &lt;code&gt;DemoClass&lt;/code&gt; objects. You’ll explore this attribute more in a moment.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;&#x27;__static_attributes__&#x27;&lt;/code&gt; key is a tuple containing the names of the attributes that you assign through &lt;code&gt;self.attribute = value&lt;/code&gt; from any method in the class body.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;&#x27;__weakref__&#x27;&lt;/code&gt; key represents a special attribute that enables you to reference objects without preventing them from being &lt;a href=&quot;/ref/glossary/garbage-collection/&quot; class=&quot;ref-link&quot;&gt;garbage collected&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally, you have the &lt;code&gt;&#x27;__doc__&#x27;&lt;/code&gt; key, which maps to the class’s docstring. If the class doesn’t have a docstring, it defaults to &lt;a href=&quot;https://realpython.com/null-in-python/&quot;&gt;&lt;code&gt;None&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Did you notice that the &lt;code&gt;.instance_attr&lt;/code&gt; name doesn’t have a key in the class &lt;code&gt;.__dict__&lt;/code&gt; attribute? You’ll find out where it’s hidden in the following section.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-dict-attribute/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-dict-attribute/ »&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>Checking for Membership Using Python&#x27;s &quot;in&quot; and &quot;not in&quot; Operators</title>
      <id>https://realpython.com/courses/checking-membership-in-not-in-operators/</id>
      <link href="https://realpython.com/courses/checking-membership-in-not-in-operators/"/>
      <updated>2025-04-08T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to check if a given value is present or absent in a collection of values using Python&#x27;s in and not in operators. This type of check is known as a membership test in Python.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;code&gt;in&lt;/code&gt; and &lt;code&gt;not in&lt;/code&gt; operators allow you to quickly check if a given value is or isn&amp;rsquo;t part of a collection of values. This type of check is generally known as a &lt;strong&gt;membership test&lt;/strong&gt; in Python. Therefore, these operators are known as &lt;strong&gt;membership operators&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;in&lt;/code&gt; operator&lt;/strong&gt; in Python is a &lt;strong&gt;membership operator&lt;/strong&gt; used to check if a value is part of a collection.&lt;/li&gt;
&lt;li&gt;You can write &lt;strong&gt;&lt;code&gt;not in&lt;/code&gt;&lt;/strong&gt; in Python to check if a value is &lt;strong&gt;absent from a collection&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Python&amp;rsquo;s membership operators work with &lt;strong&gt;several data types&lt;/strong&gt; like lists, tuples, ranges, and dictionaries.&lt;/li&gt;
&lt;li&gt;You can use &lt;strong&gt;&lt;code&gt;operator.contains()&lt;/code&gt;&lt;/strong&gt; as a function equivalent to the &lt;code&gt;in&lt;/code&gt; operator for membership testing.&lt;/li&gt;
&lt;li&gt;You can support &lt;code&gt;in&lt;/code&gt; and &lt;code&gt;not in&lt;/code&gt; in &lt;strong&gt;custom classes&lt;/strong&gt; by implementing methods like &lt;code&gt;.__contains__()&lt;/code&gt;, &lt;code&gt;.__iter__()&lt;/code&gt;, or &lt;code&gt;.__getitem__()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python News Roundup: April 2025</title>
      <id>https://realpython.com/python-news-april-2025/</id>
      <link href="https://realpython.com/python-news-april-2025/"/>
      <updated>2025-04-07T14:00:00+00:00</updated>
      <summary>Recent milestones in the Python community include Python 3.14&#x27;s sixth alpha release and the acceptance of PEP 758. PyCon US has set new records for travel grants, and Thomas Wouters receives recognition for his long-standing contributions. Popular libraries also see significant updates.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Last month brought significant progress toward Python 3.14, exciting news from PyCon US, notable community awards, and important updates to several popular Python libraries.&lt;/p&gt;
&lt;p&gt;In this news roundup, you’ll catch up on the latest Python 3.14.0a6 developments, discover which PEP has been accepted, celebrate record-breaking community support for PyCon travel grants, and explore recent updates to popular libraries. Let’s dive in!&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Join Now:&lt;/strong&gt; &lt;a href=&quot;&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-newsletter&quot; data-focus=&quot;false&quot;&gt;Click here to join the Real Python Newsletter&lt;/a&gt; and you&#x27;ll never miss another Python tutorial, course update, or post.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;python-3140a6-released-on-pi-day&quot;&gt;Python 3.14.0a6 Released on Pi Day&lt;a class=&quot;headerlink&quot; href=&quot;#python-3140a6-released-on-pi-day&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Python development team has rolled out the &lt;a href=&quot;https://blog.python.org/2025/03/python-3140-alpha-6-is-out.html&quot;&gt;sixth alpha version&lt;/a&gt; of Python 3.14, marking the penultimate release in the planned alpha series. The date of this particular preview release coincided with &lt;a href=&quot;https://en.wikipedia.org/wiki/Pi_Day&quot;&gt;Pi Day&lt;/a&gt;, which is celebrated annually on March 14 (3/14) in the honor of the mathematical constant π, traditionally marked by eating pies.&lt;/p&gt;
&lt;p&gt;As always, the changes and improvements planned for the final Python 3.14 release, which is &lt;a href=&quot;https://peps.python.org/pep-0745/&quot;&gt;slated for October&lt;/a&gt; later this year, are outlined in the &lt;a href=&quot;https://docs.python.org/3.14/whatsnew/changelog.html#python-3-14-0-alpha-6&quot;&gt;changelog&lt;/a&gt; and the &lt;a href=&quot;https://docs.python.org/3.14/&quot;&gt;online documentation&lt;/a&gt;. The major new features include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0649/&quot;&gt;PEP 649&lt;/a&gt;: &lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#pep-649-deferred-evaluation-of-annotations&quot;&gt;Deferred Evaluation of Annotations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0741/&quot;&gt;PEP 741&lt;/a&gt;: Python Configuration C API&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0761/&quot;&gt;PEP 761&lt;/a&gt;: Deprecating PGP Signatures for CPython Artifacts&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#improved-error-messages&quot;&gt;Improved Error Messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-tail-call&quot;&gt;A New Type of Interpreter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#uuid&quot;&gt;Support for UUID Versions 6, 7, and 8&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Python &lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#removed&quot;&gt;Removals&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#deprecated&quot;&gt;Deprecations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;C API &lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-c-api-removed&quot;&gt;Removals&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-c-api-deprecated&quot;&gt;Deprecations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Compared to the previous alpha release last month, Python 3.14.0a6 brings a broad mix of bug fixes, performance improvements, new features, and continued enhancements for tests and documentation. Overall, this release packs &lt;a href=&quot;https://github.com/python/cpython/compare/v3.14.0a5...v3.14.0a6&quot;&gt;nearly five hundred commits&lt;/a&gt;, most of which address specific pull requests and issues.&lt;/p&gt;
&lt;p&gt;Remember that alpha releases aren’t meant to be used in production! That said, if you’d like to get your hands dirty and give this early preview a try, then you have several choices when it comes to &lt;a href=&quot;https://realpython.com/python-pre-release/&quot;&gt;installing preview releases&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you’re a &lt;strong&gt;macOS&lt;/strong&gt; or &lt;strong&gt;Windows&lt;/strong&gt; user, then you can download the Python 3.14.0a6 installer straight from the &lt;a href=&quot;https://www.python.org/downloads/release/python-3140a6/&quot;&gt;official release page&lt;/a&gt;. To run Python without installation, which might be preferable in corporate environments, you can also download a slimmed-down, embeddable package that’s been precompiled for Windows. In such a case, you simply unpack the archive and double-click the Python executable.&lt;/p&gt;
&lt;p&gt;If you’re on &lt;strong&gt;Linux&lt;/strong&gt;, then you may find it quicker to install the latest alpha release through &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;&lt;code&gt;pyenv&lt;/code&gt;&lt;/a&gt;, which helps manage multiple Python versions alongside each other:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pyenv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;update
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pyenv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;.14.0a6
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pyenv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;shell&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;.14.0a6
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--version
&lt;span class=&quot;go&quot;&gt;Python 3.14.0a6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Don’t forget to update &lt;code&gt;pyenv&lt;/code&gt; itself first to fetch the list of available versions. Next, install Python 3.14.0a6 and set it as the default version for your current shell session. That way, when you enter &lt;code&gt;python&lt;/code&gt;, you’ll be running the sixth alpha release until you decide to close the terminal window.&lt;/p&gt;
&lt;p&gt;Alternatively, you can use &lt;a href=&quot;https://realpython.com/python-versions-docker/&quot;&gt;Docker&lt;/a&gt; to pull the corresponding image and run a container with Python 3.14.0a6 by using the following commands:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;docker&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;run&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-it&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--rm&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;python:3.14.0a6
&lt;span class=&quot;go&quot;&gt;Python 3.14.0a6 (main, Mar 18 2025, 03:31:04) [GCC 12.2.0] on linux&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;gt;&amp;gt;&amp;gt; exit&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;docker&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;run&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-it&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--rm&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-v&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;:/app&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;python:3.14.0a6&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;/app/hello.py
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first command drops you into the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;Python REPL&lt;/a&gt;, where you can interactively execute Python code and test snippets in real time. The other command mounts your current directory into the container and runs a Python script named &lt;code&gt;hello.py&lt;/code&gt; from that directory. This lets you &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run local Python scripts&lt;/a&gt; within the containerized environment.&lt;/p&gt;
&lt;p&gt;Finally, if none of the methods above work for you, then you can build the release from source code. You can get the Python source code from the downloads page mentioned earlier or by cloning the &lt;a href=&quot;https://github.com/python/cpython&quot;&gt;&lt;code&gt;python/cpython&lt;/code&gt;&lt;/a&gt; repository from GitHub:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Shell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;git&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;clone&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;git@github.com:python/cpython.git&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--branch&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;v3.14.0a6&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--single-branch
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;cpython/
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;./configure&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--enable-optimizations
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;make&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-j&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;nproc&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;./python
&lt;span class=&quot;go&quot;&gt;Python 3.14.0a6 (tags/v3.14.0a6:77b2c933ca, Mar 26 2025, 17:43:06) [GCC 13.3.0] on linux&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;--single-branch&lt;/code&gt; option tells your &lt;a href=&quot;https://realpython.com/python-git-github-intro/&quot;&gt;Git&lt;/a&gt; client to clone only the specified tag (&lt;a href=&quot;https://github.com/python/cpython/releases/tag/v3.14.0a6&quot;&gt;&lt;code&gt;v3.14.0a6&lt;/code&gt;&lt;/a&gt;) and its history without downloading all the other branches from the remote repository. The &lt;code&gt;make -j $(nproc)&lt;/code&gt; command compiles Python using all available CPU cores, which speeds up the build process significantly. Once the build is complete, you can run the newly compiled Python interpreter with &lt;code&gt;./python&lt;/code&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; To continue with the π theme, Python 3.14 includes a new &lt;a href=&quot;https://realpython.com/courses/finding-python-easter-eggs/&quot;&gt;Easter egg&lt;/a&gt;. Do you think you can find it? Let us know in the comments below!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-april-2025/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-april-2025/ »&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 #245: GUIs &amp; TUIs: Choosing a User Interface for Your Python Project</title>
      <id>https://realpython.com/podcasts/rpp/245/</id>
      <link href="https://realpython.com/podcasts/rpp/245/"/>
      <updated>2025-04-04T12:00:00+00:00</updated>
      <summary>What are the current Python graphical user interface libraries? Should you build everything in the terminal and create a text-based user interface instead? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What are the current Python graphical user interface libraries? Should you build everything in the terminal and create a text-based user interface instead? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Strip Characters From a Python String</title>
      <id>https://realpython.com/python-strip/</id>
      <link href="https://realpython.com/python-strip/"/>
      <updated>2025-04-02T14:00:00+00:00</updated>
      <summary>Use Python&#x27;s .strip() method to remove unwanted whitespace or specific characters. Learn about common pitfalls, real-world use cases, and compare .strip() with similar methods like .lstrip() and .removesuffix().</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;By default, Python’s &lt;code&gt;.strip()&lt;/code&gt; method removes whitespace characters from both ends of a string. To remove different characters, you can pass a string as an argument that specifies a set of characters to remove. The &lt;code&gt;.strip()&lt;/code&gt; method is useful for tasks like cleaning user input, standardizing filenames, and preparing data for storage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;.strip()&lt;/code&gt; method &lt;strong&gt;removes leading and trailing whitespace&lt;/strong&gt; but doesn’t remove whitespace from the middle of a string.&lt;/li&gt;
&lt;li&gt;You can use &lt;code&gt;.strip()&lt;/code&gt; to remove &lt;strong&gt;specified characters&lt;/strong&gt; from both ends of the string by providing these characters as an &lt;strong&gt;argument&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;With the related methods &lt;strong&gt;&lt;code&gt;.lstrip()&lt;/code&gt; and &lt;code&gt;.rstrip()&lt;/code&gt;&lt;/strong&gt;, you can remove characters from &lt;strong&gt;one side&lt;/strong&gt; of the string only.&lt;/li&gt;
&lt;li&gt;All three methods, &lt;code&gt;.strip()&lt;/code&gt;, &lt;code&gt;.lstrip()&lt;/code&gt;, and &lt;code&gt;.rstrip()&lt;/code&gt;, &lt;strong&gt;remove character sets, not sequences&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You can use &lt;strong&gt;&lt;code&gt;.removeprefix()&lt;/code&gt; and &lt;code&gt;.removesuffix()&lt;/code&gt;&lt;/strong&gt; to &lt;strong&gt;strip character sequences&lt;/strong&gt; from the start or end of a string.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, you’ll explore the nuances of &lt;code&gt;.strip()&lt;/code&gt; and other Python string methods that allow you to strip parts of a string. You’ll also learn about common pitfalls and read about practical real-world scenarios, such as cleaning datasets and standardizing user input.
To get the most out of this tutorial, you should have a basic understanding of &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;Python strings and character data&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-strip-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-strip-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code &lt;/a&gt; that shows you how to strip characters from a Python string.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “How to Strip Characters From a Python String” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-strip/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #ffc973;&quot; alt=&quot;How to Strip Characters From a Python String?&quot; src=&quot;https://files.realpython.com/media/How-to-Strip-Characters-from-a-Python-String_Watermarked.00bc2bde8568.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/How-to-Strip-Characters-from-a-Python-String_Watermarked.00bc2bde8568.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Strip-Characters-from-a-Python-String_Watermarked.00bc2bde8568.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Strip-Characters-from-a-Python-String_Watermarked.00bc2bde8568.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Strip-Characters-from-a-Python-String_Watermarked.00bc2bde8568.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-strip/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Strip Characters From a Python String&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python&#x27;s .strip(), .lstrip(), and .rstrip() methods, as well as .removeprefix() and .removesuffix(). These methods are useful for tasks like cleaning user input, standardizing filenames, and preparing data for storage.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;how-to-use-pythons-strip-method-to-remove-whitespace-from-strings&quot;&gt;How to Use Python’s &lt;code&gt;.strip()&lt;/code&gt; Method to Remove Whitespace From Strings&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-use-pythons-strip-method-to-remove-whitespace-from-strings&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s &lt;code&gt;.strip()&lt;/code&gt; method provides a quick and reliable way to remove unwanted spaces, tabs, and newline characters from both the beginning and end of a &lt;a href=&quot;/ref/builtin-types/str/&quot; class=&quot;ref-link&quot;&gt;string&lt;/a&gt;. This makes it useful for tasks like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Validating user input&lt;/strong&gt;, such as trimming spaces from email addresses, usernames, and other user-provided data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cleaning messy text&lt;/strong&gt; gathered through &lt;a href=&quot;https://realpython.com/python-web-scraping-practical-introduction/&quot;&gt;web scraping&lt;/a&gt; or other sources.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preparing data for storage&lt;/strong&gt; to ensure uniformity before saving text to a database.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Standardizing logs&lt;/strong&gt; by removing unwanted spaces.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you don’t provide any &lt;a href=&quot;/ref/glossary/argument/&quot; class=&quot;ref-link&quot;&gt;arguments&lt;/a&gt; to the method, then &lt;code&gt;.strip()&lt;/code&gt; removes all leading and trailing whitespace characters, leaving any whitespace within the string untouched:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;original_string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;   Hello, World!   &quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;original_string&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Hello, World!&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When you call &lt;code&gt;.strip()&lt;/code&gt; on a string &lt;a href=&quot;/ref/glossary/object/&quot; class=&quot;ref-link&quot;&gt;object&lt;/a&gt;, Python removes the leading and trailing spaces while keeping the spaces between words unchanged, like in &lt;code&gt;&quot;Hello,&quot;&lt;/code&gt; and &lt;code&gt;&quot;World!&quot;&lt;/code&gt;. This can be a great way to clean up text data without affecting the content itself.&lt;/p&gt;
&lt;p&gt;However, whitespace isn’t just about spaces—it also includes common characters such as newlines (&lt;code&gt;\n&lt;/code&gt;) and tabs (&lt;code&gt;\t&lt;/code&gt;). These often appear when you’re dealing with multi-line strings or reading data from files. The default invocation of &lt;code&gt;.strip()&lt;/code&gt; effectively removes them as well:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n\t&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;  This is a messy multi-line string.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;This is a messy multi-line string.&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here, &lt;code&gt;.strip()&lt;/code&gt; removes all leading and trailing whitespace characters, including newlines and tabs, leaving only the text content. After having cleaned your strings using &lt;code&gt;.strip()&lt;/code&gt;, they’re in better condition for displaying or further processing the text. This can be especially useful when you’re dealing with structured data, such as logs or CSV files, where you need to process many strings in a row.&lt;/p&gt;
&lt;p&gt;At this point, you’ve learned how &lt;code&gt;.strip()&lt;/code&gt; handles whitespace removal. But what if you need to strip specific characters, not just whitespace? In the next section, you’ll see how you can use this method to remove any unwanted characters from the start and end of a string.&lt;/p&gt;
&lt;h2 id=&quot;remove-specific-characters-with-strip&quot;&gt;Remove Specific Characters With &lt;code&gt;.strip()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#remove-specific-characters-with-strip&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sometimes, you need to remove specific characters other than whitespace. For example, when your text is delimited by unwanted symbols, or when you have to handle text that’s plagued by formatting issues. You can use &lt;code&gt;.strip()&lt;/code&gt; to remove specific characters by passing these characters as an argument to the method:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;python_syntax&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python Syntax&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;cleaned_string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;original_string&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chars&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here, &lt;code&gt;chars&lt;/code&gt; is a string argument that you can pass to &lt;code&gt;.strip()&lt;/code&gt;. If you don’t pass it, then it defaults to &lt;code&gt;None&lt;/code&gt;, which means the method will remove whitespace characters.&lt;/p&gt;
&lt;p&gt;Instead, you can pass a string value that contains all the characters needing removal from both ends of the target string. Note that &lt;code&gt;.strip()&lt;/code&gt; doesn’t treat the argument as a prefix or suffix, but rather as a set of individual characters to strip. In the rest of this section, you’ll explore use cases of passing specific characters to &lt;code&gt;.strip()&lt;/code&gt; for cleaning the beginning and end of a string.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.strip()&lt;/code&gt; method is useful when you want to remove punctuation marks, specific symbols, or other unwanted characters. For example, in &lt;a href=&quot;https://realpython.com/python-nltk-sentiment-analysis/&quot;&gt;sentiment analysis&lt;/a&gt; tasks, you may need to remove question marks or exclamation marks from text data:&lt;/p&gt;
&lt;div class=&quot;codeblock mb-3 w-100&quot; aria-label=&quot;Code block&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header d-flex justify-content-between codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot; aria-label=&quot;Language&quot;&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; role=&quot;button&quot;&gt;&lt;span class=&quot;icon baseline js-codeblock-output-on codeblock__header--icon-lower&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#regular--rectangle-terminal&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style=&quot;position: relative;&quot;&gt;
    &lt;div class=&quot;highlight highlight--with-header&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;review&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;!!This product is incredible!!!&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;review&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;This product is incredible&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;template class=&quot;codeblock__copied-template&quot;&gt;
      &lt;span class=&quot;small&quot;&gt;&lt;span class=&quot;icon baseline mr-1 text-success&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Copied!&lt;/span&gt;
    &lt;/template&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Since you pass &lt;code&gt;&quot;!&quot;&lt;/code&gt; as an argument, &lt;code&gt;.strip()&lt;/code&gt; removes all exclamation marks from both ends of the string while leaving the text content intact. Keep in mind that &lt;code&gt;.strip()&lt;/code&gt; removes all occurrences of the specified characters at once, not just the first one it encounters.&lt;/p&gt;
&lt;p&gt;You can also use &lt;code&gt;.strip()&lt;/code&gt; to remove multiple specified characters from both ends of a string. For example, some of the product reviews you’re dealing with may be in Spanish and use a combination of exclamation marks and inverted exclamation marks:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-strip/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-strip/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Building a Code Image Generator With Python</title>
      <id>https://realpython.com/courses/code-image-generator/</id>
      <link href="https://realpython.com/courses/code-image-generator/"/>
      <updated>2025-04-01T14:00:00+00:00</updated>
      <summary>In this step-by-step video course, you&#x27;ll build a code image generator that creates nice-looking images of your code snippets to share on social media. Your code image generator will be powered by the Flask web framework and include exciting packages like Pygments and Playwright.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re active on social media, then you know that images and videos are popular forms of content. As a programmer, you mainly work with text, so sharing the content that you create on a daily basis may not seem intuitive. That&amp;rsquo;s where a code image generator comes in handy!&lt;/p&gt;
&lt;p&gt;A code image generator allows you to turn your code snippets into visually appealing images, so you can share your work without worrying about formatting issues, syntax highlighting inconsistencies, or character count limits.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this step-by-step video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set up and run a &lt;strong&gt;Flask project&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Connect and style &lt;strong&gt;Jinja templates&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Playwright&lt;/strong&gt; to create images&lt;/li&gt;
&lt;li&gt;Beautify code with &lt;strong&gt;Pygments&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Leverage &lt;strong&gt;sessions&lt;/strong&gt; to save browser states&lt;/li&gt;
&lt;li&gt;Enhance the user experience with &lt;strong&gt;JavaScript&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s Bytearray: A Mutable Sequence of Bytes</title>
      <id>https://realpython.com/python-bytearray/</id>
      <link href="https://realpython.com/python-bytearray/"/>
      <updated>2025-03-31T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about Python&#x27;s bytearray, a mutable sequence of bytes for efficient binary data manipulation. You&#x27;ll explore how it differs from bytes, how to create and modify bytearray objects, and when to use them in tasks like processing binary files and network protocols.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s &lt;code&gt;bytearray&lt;/code&gt; is a mutable sequence of bytes that allows you to manipulate binary data efficiently. Unlike immutable &lt;code&gt;bytes&lt;/code&gt;, &lt;code&gt;bytearray&lt;/code&gt; can be modified in place, making it suitable for tasks requiring frequent updates to byte sequences.&lt;/p&gt;
&lt;p&gt;You can create a &lt;code&gt;bytearray&lt;/code&gt; using the &lt;code&gt;bytearray()&lt;/code&gt; constructor with various arguments or from a string of hexadecimal digits using &lt;code&gt;.fromhex()&lt;/code&gt;. This tutorial explores creating, modifying, and using &lt;code&gt;bytearray&lt;/code&gt; objects in Python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A &lt;code&gt;bytearray&lt;/code&gt; in Python&lt;/strong&gt; is a mutable sequence of bytes that allows in-place modifications, unlike the immutable &lt;code&gt;bytes&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You create a &lt;code&gt;bytearray&lt;/code&gt;&lt;/strong&gt; by using the &lt;code&gt;bytearray()&lt;/code&gt; constructor with a non-negative integer, iterable of integers, bytes-like object, or a string with specified encoding.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You can modify a &lt;code&gt;bytearray&lt;/code&gt;&lt;/strong&gt; in Python by appending, slicing, or changing individual bytes, thanks to its mutable nature.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Common uses for &lt;code&gt;bytearray&lt;/code&gt;&lt;/strong&gt; include processing large binary files, working with network protocols, and tasks needing frequent updates to byte sequences.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll dive deeper into each aspect of &lt;code&gt;bytearray&lt;/code&gt;, exploring its creation, manipulation, and practical applications in Python programming.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-bytearray-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-bytearray-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to learn about Python’s bytearray data type.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;container border rounded text-wrap-pretty my-3&quot;&gt;

  &lt;p class=&quot;my-3&quot;&gt;&lt;mark class=&quot;marker-highlight&quot;&gt;&lt;strong&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Python&#x27;s Bytearray” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

  &lt;div class=&quot;row my-3&quot;&gt;
    &lt;div class=&quot;col-xs-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-bytearray/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;embed-responsive embed-responsive-16by9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 embed-responsive-item rounded&quot; style=&quot;object-fit: contain; background: #b9abe6;&quot; alt=&quot;Python&#x27;s Bytearray: A Mutable Sequence of Bytes&quot; src=&quot;https://files.realpython.com/media/Pythons-Bytearray_Watermarked.736fb67a3a9a.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Pythons-Bytearray_Watermarked.736fb67a3a9a.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Pythons-Bytearray_Watermarked.736fb67a3a9a.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Pythons-Bytearray_Watermarked.736fb67a3a9a.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Pythons-Bytearray_Watermarked.736fb67a3a9a.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)&quot;&gt;


          &lt;div class=&quot;card-img-overlay d-flex align-items-center&quot;&gt;
            &lt;div class=&quot;mx-auto&quot;&gt;
              &lt;span class=&quot;text-light&quot; style=&quot;opacity: 0.90;&quot;&gt;&lt;span class=&quot;icon baseline scale2x&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.6eec2e95bede.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col&quot;&gt;
      &lt;div class=&quot;mt-3 d-md-none&quot;&gt;&lt;/div&gt; 
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Interactive Quiz&lt;/strong&gt;&lt;/p&gt;
      &lt;a href=&quot;/quizzes/python-bytearray/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python&#x27;s Bytearray&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python&#x27;s bytearray data type. By working through this quiz, you&#x27;ll revisit the key concepts and uses of bytearray in Python.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;understanding-pythons-bytearray-type&quot;&gt;Understanding Python’s &lt;code&gt;bytearray&lt;/code&gt; Type&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-pythons-bytearray-type&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although Python remains a high-level programming language, it exposes a few specialized data types that let you manipulate binary data directly should you ever need to. These data types can be useful for tasks such as processing custom binary file formats, or working with low-level network protocols requiring precise control over the data.&lt;/p&gt;
&lt;p&gt;The three closely related &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#binaryseq&quot;&gt;binary sequence types&lt;/a&gt; built into the language are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;bytes&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bytearray&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;memoryview&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While they’re all &lt;a href=&quot;https://realpython.com/python-sequences/&quot;&gt;Python sequences&lt;/a&gt; optimized for performance when dealing with binary data, they each have slightly different strengths and use cases.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You’ll take a deep dive into Python’s &lt;code&gt;bytearray&lt;/code&gt; in this tutorial. But, if you’d like to learn more about the companion &lt;code&gt;bytes&lt;/code&gt; data type, then check out &lt;a href=&quot;https://realpython.com/python-bytes/&quot;&gt;Bytes Objects: Handling Binary Data in Python&lt;/a&gt;, which also covers binary data fundamentals.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;As both names suggest, &lt;a href=&quot;/ref/builtin-types/bytes/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;bytes&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;/ref/builtin-types/bytearray/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;bytearray&lt;/code&gt;&lt;/a&gt; are sequences of individual &lt;em&gt;byte&lt;/em&gt; values, letting you process binary data at the &lt;strong&gt;byte level&lt;/strong&gt;. For example, you may use them to work with plain text data, which typically represents characters as unique byte values, depending on the given &lt;a href=&quot;https://realpython.com/python-encodings-guide/&quot;&gt;character encoding&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Python natively interprets bytes as 8-bit &lt;a href=&quot;https://realpython.com/python-bitwise-operators/#unsigned-integers&quot;&gt;unsigned integers&lt;/a&gt;, each representing one of 256 possible values (2&lt;sup&gt;8&lt;/sup&gt;) between 0 and 255. But sometimes, you may need to interpret the same bit pattern as a &lt;a href=&quot;https://realpython.com/python-bitwise-operators/#signed-integers&quot;&gt;signed integer&lt;/a&gt;, for example, when handling digital audio samples that encode a sound wave’s amplitude levels. See the &lt;a href=&quot;https://realpython.com/python-bytes/#signedness-and-the-sign-bit&quot;&gt;section on signedness&lt;/a&gt; in the Python &lt;code&gt;bytes&lt;/code&gt; tutorial for more details.&lt;/p&gt;
&lt;p&gt;The choice between &lt;code&gt;bytes&lt;/code&gt; and &lt;code&gt;bytearray&lt;/code&gt; boils down to whether you want read-only access to the underlying bytes or not. Instances of the &lt;code&gt;bytes&lt;/code&gt; data type are &lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/&quot;&gt;immutable&lt;/a&gt;, meaning each one has a fixed value that you can’t change once the object is created. In contrast, &lt;code&gt;bytearray&lt;/code&gt; objects are &lt;strong&gt;mutable sequences&lt;/strong&gt;, allowing you to modify their contents after creation.&lt;/p&gt;
&lt;p&gt;While it may seem counterintuitive at first—since many newcomers to Python expect objects to be directly modifiable—immutable objects have several benefits over their mutable counterparts. That’s why types like strings, tuples, and others require reassignment in Python.&lt;/p&gt;
&lt;p&gt;The advantages of immutable data types include better memory efficiency due to the ability to &lt;a href=&quot;https://realpython.com/lru-cache-python/&quot;&gt;cache&lt;/a&gt; or reuse objects without unnecessary copying. In Python, immutable objects are inherently &lt;a href=&quot;/ref/glossary/hashable/&quot; class=&quot;ref-link&quot;&gt;hashable&lt;/a&gt;, so they can become &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt; keys or &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;set&lt;/a&gt; elements. Additionally, relying on immutable objects gives you extra security, data integrity, and &lt;a href=&quot;https://realpython.com/python-thread-lock/&quot;&gt;thread safety&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;That said, if you need a binary sequence that allows for modification, then &lt;code&gt;bytearray&lt;/code&gt; is the way to go. Use it when you frequently perform &lt;a href=&quot;https://en.wikipedia.org/wiki/In-place_algorithm&quot;&gt;in-place&lt;/a&gt; byte operations that involve changing the contents of the sequence, such as appending, inserting, extending, or modifying individual bytes. A scenario where &lt;code&gt;bytearray&lt;/code&gt; can be particularly useful includes processing large binary files in chunks or incrementally reading messages from a network buffer.&lt;/p&gt;
&lt;p&gt;The third binary sequence type in Python mentioned earlier, &lt;a href=&quot;/ref/builtin-functions/memoryview/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;memoryview&lt;/code&gt;&lt;/a&gt;, provides a zero-overhead view into the memory of certain objects. Unlike &lt;code&gt;bytes&lt;/code&gt; and &lt;code&gt;bytearray&lt;/code&gt;, whose mutability status is fixed, a &lt;code&gt;memoryview&lt;/code&gt; can be either mutable or immutable depending on the target object it references. Just like &lt;code&gt;bytes&lt;/code&gt; and &lt;code&gt;bytearray&lt;/code&gt;, a &lt;code&gt;memoryview&lt;/code&gt; may represent a series of single bytes, but at the same time, it can represent a sequence of &lt;a href=&quot;https://en.wikipedia.org/wiki/Word_(computer_architecture)&quot;&gt;multi-byte words&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now that you have a basic understanding of Python’s binary sequence types and where &lt;code&gt;bytearray&lt;/code&gt; fits into them, you can explore ways to create and work with &lt;code&gt;bytearray&lt;/code&gt; objects in Python.&lt;/p&gt;
&lt;h2 id=&quot;creating-bytearray-objects-in-python&quot;&gt;Creating &lt;code&gt;bytearray&lt;/code&gt; Objects in Python&lt;a class=&quot;headerlink&quot; href=&quot;#creating-bytearray-objects-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Unlike the immutable &lt;code&gt;bytes&lt;/code&gt; data type, whose &lt;a href=&quot;https://realpython.com/python-bytes/#the-bytes-literal-format&quot;&gt;literal form&lt;/a&gt; resembles a string literal prefixed with the letter &lt;code&gt;b&lt;/code&gt;—for example, &lt;code&gt;b&quot;GIF89a&quot;&lt;/code&gt;—the mutable &lt;code&gt;bytearray&lt;/code&gt; has &lt;strong&gt;no literal syntax&lt;/strong&gt; in Python. This distinction is important despite many similarities between both byte-oriented sequences, which you’ll discover in the next section.&lt;/p&gt;
&lt;p&gt;The primary way to create new &lt;code&gt;bytearray&lt;/code&gt; instances is by explicitly calling the type’s &lt;a href=&quot;https://realpython.com/python-class-constructor/&quot;&gt;class constructor&lt;/a&gt;, sometimes informally known as the &lt;code&gt;bytearray()&lt;/code&gt; &lt;a href=&quot;https://realpython.com/python-built-in-functions/&quot;&gt;built-in function&lt;/a&gt;. Alternatively, you can create a &lt;code&gt;bytearray&lt;/code&gt; from a string of hexadecimal digits. You’ll learn about both methods next.&lt;/p&gt;
&lt;h3 id=&quot;the-bytearray-constructor&quot;&gt;The &lt;code&gt;bytearray()&lt;/code&gt; Constructor&lt;a class=&quot;headerlink&quot; href=&quot;#the-bytearray-constructor&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-bytearray/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-bytearray/ »&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>Quiz: Using Python&#x27;s .__dict__ to Work With Attributes</title>
      <id>https://realpython.com/quizzes/python-dict-attribute/</id>
      <link href="https://realpython.com/quizzes/python-dict-attribute/"/>
      <updated>2025-03-27T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python&#x27;s .__dict__ attribute and its usage in classes, instances, and functions. Acting as a namespace, this attribute maps attribute names to their corresponding values and serves as a versatile tool for metaprogramming and debugging.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/python-dict-attribute/&quot;&gt;Using Python&amp;rsquo;s &lt;code&gt;.__dict__&lt;/code&gt; to Work With Attributes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how &lt;code&gt;.__dict__&lt;/code&gt; holds an object&amp;rsquo;s writable attributes, allowing for dynamic manipulation and introspection. You&amp;rsquo;ll also review how both &lt;code&gt;vars()&lt;/code&gt; and &lt;code&gt;.__dict__&lt;/code&gt; let you inspect an object&amp;rsquo;s attributes, and the common use cases of &lt;code&gt;.__dict__&lt;/code&gt; in Python applications.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>What Can You Do With Python?</title>
      <id>https://realpython.com/courses/what-can-you-do-with-python/</id>
      <link href="https://realpython.com/courses/what-can-you-do-with-python/"/>
      <updated>2025-03-25T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll find a set of guidelines that will help you start applying your Python skills to solve real-world problems. By the end, you&#x27;ll be able to answer the question, &quot;What can you do with Python?&quot;</summary>
      <content type="html">
        &lt;p&gt;You&amp;rsquo;ve finished a course or finally made it to the end of a &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;book&lt;/a&gt; that teaches you the &lt;a href=&quot;https://realpython.com/learning-paths/python3-introduction/&quot;&gt;basics of programming with Python&lt;/a&gt;. You&amp;rsquo;ve learned about &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;lists, tuples&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-while-loop/&quot;&gt;&lt;code&gt;while&lt;/code&gt;&lt;/a&gt; loops, &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional statements&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented concepts&lt;/a&gt;, and more. So, what&amp;rsquo;s next? What can you do with Python nowadays?&lt;/p&gt;
&lt;p&gt;Python is a versatile programming language with many use cases in a variety of different fields. If you&amp;rsquo;ve grasped the basics of Python and are itching to build something with the language, then it&amp;rsquo;s time to figure out what your next step should be.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll see how you can use Python for:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Doing general &lt;strong&gt;software development&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Diving into &lt;strong&gt;data science and math&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Speeding up and automating your &lt;strong&gt;workflow&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Building &lt;strong&gt;embedded systems&lt;/strong&gt; and &lt;strong&gt;robots&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: GitHub Actions for Python</title>
      <id>https://realpython.com/quizzes/github-actions-python/</id>
      <link href="https://realpython.com/quizzes/github-actions-python/"/>
      <updated>2025-03-25T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of GitHub Actions for Python. By working through this quiz, you&#x27;ll revisit how to use GitHub Actions and workflows to automate linting, testing, and deployment of a Python project.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/github-actions-python/&quot;&gt;Continuous Integration and Deployment for Python With GitHub Actions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to use GitHub Actions and workflows to automate linting, testing, and deployment of a Python project. You&amp;rsquo;ll also review how to secure your credentials and automate security and dependency updates.&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>Quiz: Python&#x27;s Instance, Class, and Static Methods Demystified</title>
      <id>https://realpython.com/quizzes/instance-class-and-static-methods-demystified/</id>
      <link href="https://realpython.com/quizzes/instance-class-and-static-methods-demystified/"/>
      <updated>2025-03-25T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of instance, class, and static methods in Python. By working through this quiz, you&#x27;ll revisit the differences between these methods and how to use them effectively in your Python code.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/&quot;&gt;Instance, Class, and Static Methods in Python&lt;/a&gt;. By working through this quiz, you&amp;rsquo;ll revisit the differences between these methods and how to use them effectively in your Python code.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Python Set Comprehensions: How and When to Use Them</title>
      <id>https://realpython.com/quizzes/python-set-comprehension/</id>
      <link href="https://realpython.com/quizzes/python-set-comprehension/"/>
      <updated>2025-03-25T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python set comprehensions. Set comprehensions are a concise and quick way to create, transform, and filter sets in Python. They can significantly enhance your code&#x27;s conciseness and readability compared to using regular for loops to process your sets.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your understanding of &lt;a href=&quot;https://realpython.com/python-set-comprehension/&quot;&gt;Python Set Comprehensions: How and When to Use Them&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Set comprehensions are a concise and quick way to create, transform, and filter sets in Python.
They can significantly enhance your code&amp;rsquo;s conciseness and readability compared to using regular &lt;code&gt;for&lt;/code&gt; loops to process your sets.&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 #244: A Decade of Automating the Boring Stuff With Python</title>
      <id>https://realpython.com/podcasts/rpp/244/</id>
      <link href="https://realpython.com/podcasts/rpp/244/"/>
      <updated>2025-03-21T12:00:00+00:00</updated>
      <summary>What goes into updating one of the most popular books about working with Python? After a decade of changes in the Python landscape, what projects, libraries, and skills are relevant to an office worker? This week on the show, we speak with previous guest Al Sweigart about the third edition of &quot;Automate the Boring Stuff With Python.&quot;</summary>
      <content type="html">
        &lt;p&gt;What goes into updating one of the most popular books about working with Python? After a decade of changes in the Python landscape, what projects, libraries, and skills are relevant to an office worker? This week on the show, we speak with previous guest Al Sweigart about the third edition of &quot;Automate the Boring Stuff With Python.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Using Structural Pattern Matching in Python</title>
      <id>https://realpython.com/courses/structural-pattern-matching/</id>
      <link href="https://realpython.com/courses/structural-pattern-matching/"/>
      <updated>2025-03-18T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to harness the power of structural pattern matching in Python. You&#x27;ll explore the new syntax, delve into various pattern types, and find appropriate applications for pattern matching, all while identifying common pitfalls.</summary>
      <content type="html">
        &lt;p&gt;Structural pattern matching is a powerful &lt;strong&gt;control flow construct&lt;/strong&gt; invented decades ago that&amp;rsquo;s traditionally used by compiled languages, especially within the &lt;a href=&quot;https://realpython.com/python-functional-programming/&quot;&gt;functional programming paradigm&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Most mainstream programming languages have since adopted some form of pattern matching, which offers concise and readable syntax while promoting a declarative code style. Although Python was late to join the party, it introduced structural pattern matching in the &lt;a href=&quot;https://realpython.com/python310-new-features/&quot;&gt;3.10&lt;/a&gt; release.&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;Master the &lt;strong&gt;syntax&lt;/strong&gt; of the &lt;code&gt;match&lt;/code&gt; statement and &lt;code&gt;case&lt;/code&gt; clauses&lt;/li&gt;
&lt;li&gt;Explore various &lt;strong&gt;types of patterns&lt;/strong&gt; supported by Python&lt;/li&gt;
&lt;li&gt;Learn about &lt;strong&gt;guards&lt;/strong&gt;, &lt;strong&gt;unions&lt;/strong&gt;, &lt;strong&gt;aliases&lt;/strong&gt;, and &lt;strong&gt;name binding&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Extract values from deeply nested &lt;strong&gt;hierarchical data structures&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Customize pattern matching for &lt;strong&gt;user-defined classes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Identify and avoid &lt;strong&gt;common pitfalls&lt;/strong&gt; in Python&amp;rsquo;s pattern matching&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #243: Manage Projects With pyproject.toml &amp; Explore Polars LazyFrames</title>
      <id>https://realpython.com/podcasts/rpp/243/</id>
      <link href="https://realpython.com/podcasts/rpp/243/"/>
      <updated>2025-03-14T12:00:00+00:00</updated>
      <summary>How can you simplify the management of your Python projects with one file? What are the advantages of using LazyFrames in Polars? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How can you simplify the management of your Python projects with one file? What are the advantages of using LazyFrames in Polars? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Getting to Know Duck Typing in Python</title>
      <id>https://realpython.com/courses/duck-typing-python/</id>
      <link href="https://realpython.com/courses/duck-typing-python/"/>
      <updated>2025-03-11T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about duck typing in Python---a type system based on an object&#x27;s behavior rather than inheritance. By taking advantage of duck typing, you can create flexible and decoupled sets of Python classes that work together or independently.</summary>
      <content type="html">
        &lt;p&gt;Python makes extensive use of a &lt;a href=&quot;https://realpython.com/python-type-checking/#type-systems&quot;&gt;type system&lt;/a&gt; known as &lt;strong&gt;duck typing&lt;/strong&gt;. This system is based on an object&amp;rsquo;s behavior and interface. Many built-in classes and tools support this type system, which makes them pretty flexible and decoupled.&lt;/p&gt;
&lt;p&gt;Duck typing is a core concept in Python. Understanding it will give you deeper insight into how the language works and, more importantly, how to use this approach in your own code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;duck typing&lt;/strong&gt; is and what its pros and cons are&lt;/li&gt;
&lt;li&gt;How Python&amp;rsquo;s classes and tools &lt;strong&gt;take advantage of duck typing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;special methods&lt;/strong&gt; and &lt;strong&gt;protocols&lt;/strong&gt; support duck typing&lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;alternatives&lt;/strong&gt; to duck typing are in Python&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #242: Eric Matthes: Maybe Don&#x27;t Start With Unit Tests</title>
      <id>https://realpython.com/podcasts/rpp/242/</id>
      <link href="https://realpython.com/podcasts/rpp/242/"/>
      <updated>2025-03-07T12:00:00+00:00</updated>
      <summary>Should you always start testing your code with unit tests? When does it make sense to look at integration or end-to-end testing as a first step instead? This week on the show, we speak with previous guest Eric Matthes about where to begin testing your code.</summary>
      <content type="html">
        &lt;p&gt;Should you always start testing your code with unit tests? When does it make sense to look at integration or end-to-end testing as a first step instead? This week on the show, we speak with previous guest Eric Matthes about where to begin testing your code.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Working With Python Polars</title>
      <id>https://realpython.com/courses/working-with-python-polars/</id>
      <link href="https://realpython.com/courses/working-with-python-polars/"/>
      <updated>2025-03-04T14:00:00+00:00</updated>
      <summary>Welcome to the world of Polars, a powerful DataFrame library for Python. In this video course, you&#x27;ll get a hands-on introduction to Polars&#x27; core features and see why this library is catching so much buzz.</summary>
      <content type="html">
        &lt;p&gt;In the world of data analysis and manipulation, Python has long been the go-to language. With extensive and user-friendly libraries like &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/pyspark-intro/&quot;&gt;PySpark&lt;/a&gt;, there&amp;rsquo;s a solution available for almost any data-driven task. Among these libraries, one name that&amp;rsquo;s been generating a significant amount of buzz lately is &lt;a href=&quot;https://pola-rs.github.io/polars-book/&quot;&gt;Polars&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Polars is a high-performance DataFrame library, designed to provide fast and efficient data processing capabilities. Inspired by the reigning pandas library, Polars takes things to another level, offering a seamless experience for working with large datasets that might not fit into memory.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why Polars is so &lt;strong&gt;performant&lt;/strong&gt; and attention-grabbing&lt;/li&gt;
&lt;li&gt;How to work with &lt;strong&gt;DataFrames&lt;/strong&gt;, &lt;strong&gt;expressions&lt;/strong&gt;, and &lt;strong&gt;contexts&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;read&lt;/strong&gt; data into &lt;strong&gt;DataFrames&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;group&lt;/strong&gt; and &lt;strong&gt;aggregate&lt;/strong&gt; data &lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;lazy API&lt;/strong&gt; is and how to build &lt;strong&gt;lazy queries&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #241: Deciphering Python Jargon &amp; Compiling Python 1.0</title>
      <id>https://realpython.com/podcasts/rpp/241/</id>
      <link href="https://realpython.com/podcasts/rpp/241/"/>
      <updated>2025-02-28T12:00:00+00:00</updated>
      <summary>How do you learn the terms commonly used when speaking about Python? How is the jargon similar to other programming languages? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How do you learn the terms commonly used when speaking about Python? How is the jargon similar to other programming languages? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Single and Double Underscore Naming Conventions in Python</title>
      <id>https://realpython.com/courses/single-double-underscore-naming-conventions/</id>
      <link href="https://realpython.com/courses/single-double-underscore-naming-conventions/"/>
      <updated>2025-02-25T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn a few Python naming conventions involving single and double underscores (_). You&#x27;ll learn how to use this character to differentiate between public and non-public names in APIs, write safe classes for subclassing purposes, avoid name clashes, and more.</summary>
      <content type="html">
        &lt;p&gt;Python has a few important &lt;strong&gt;naming conventions&lt;/strong&gt; that are based on using either a single or double &lt;strong&gt;underscore&lt;/strong&gt; character (&lt;code&gt;_&lt;/code&gt;). These conventions allow you to differentiate between public and non-public names in APIs, write safe classes for subclassing purposes, avoid name clashes, and more.&lt;/p&gt;
&lt;p&gt;Following and respecting these conventions allows you to write code that looks Pythonic and consistent in the eyes of other Python developers. This skill is especially useful when you&amp;rsquo;re writing code that&amp;rsquo;s intended for other developers to work with.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn about Python &lt;strong&gt;naming conventions&lt;/strong&gt; that rely on using &lt;strong&gt;underscores&lt;/strong&gt; (&lt;code&gt;_&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Differentiate &lt;strong&gt;public&lt;/strong&gt; and &lt;strong&gt;non-public&lt;/strong&gt; names by using a single leading underscore&lt;/li&gt;
&lt;li&gt;Use double leading underscores to leverage &lt;strong&gt;name mangling&lt;/strong&gt; in Python classes&lt;/li&gt;
&lt;li&gt;Explore other &lt;strong&gt;common uses&lt;/strong&gt; of underscores in Python names&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #240: Telling Effective Stories With Your Python Visualizations</title>
      <id>https://realpython.com/podcasts/rpp/240/</id>
      <link href="https://realpython.com/podcasts/rpp/240/"/>
      <updated>2025-02-21T12:00:00+00:00</updated>
      <summary>How do you make compelling visualizations that best convey the story of your data? What methods can you employ within popular Python tools to improve your plots and graphs? This week on the show, Matt Harrison returns to discuss his new book &quot;Effective Visualization: Exploiting Matplotlib &amp; Pandas.&quot;</summary>
      <content type="html">
        &lt;p&gt;How do you make compelling visualizations that best convey the story of your data? What methods can you employ within popular Python tools to improve your plots and graphs? This week on the show, Matt Harrison returns to discuss his new book &quot;Effective Visualization: Exploiting Matplotlib &amp; Pandas.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #239: Behavior-Driven vs Test-Driven Development &amp; Using Regex in Python</title>
      <id>https://realpython.com/podcasts/rpp/239/</id>
      <link href="https://realpython.com/podcasts/rpp/239/"/>
      <updated>2025-02-14T12:00:00+00:00</updated>
      <summary>What is behavior-driven development, and how does it work alongside test-driven development? How do you communicate requirements between teams in an organization? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What is behavior-driven development, and how does it work alongside test-driven development? How do you communicate requirements between teams in an organization? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #238: Charlie Marsh: Accelerating Python Tooling With Ruff and uv</title>
      <id>https://realpython.com/podcasts/rpp/238/</id>
      <link href="https://realpython.com/podcasts/rpp/238/"/>
      <updated>2025-02-07T12:00:00+00:00</updated>
      <summary>Are you looking for fast tools to lint your code and manage your projects? How is the Rust programming language being used to speed up Python tools? This week on the show, we speak with Charlie Marsh about his company, Astral, and their tools, uv and Ruff.</summary>
      <content type="html">
        &lt;p&gt;Are you looking for fast tools to lint your code and manage your projects? How is the Rust programming language being used to speed up Python tools? This week on the show, we speak with Charlie Marsh about his company, Astral, and their tools, uv and Ruff.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  

</feed>
