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

  
    <entry>
      <title>The Real Python Podcast – Episode #296: Managing Polars Schema Issues &amp; Profiling GitHub Users</title>
      <id>https://realpython.com/podcasts/rpp/296/</id>
      <link href="https://realpython.com/podcasts/rpp/296/"/>
      <updated>2026-05-22T12:00:00+00:00</updated>
      <summary>How can you avoid schema problems in your Polars data pipeline when adding new columns? How can you quickly examine a GitHub user&#x27;s profile to decide how much to invest in their contributions? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How can you avoid schema problems in your Polars data pipeline when adding new columns? How can you quickly examine a GitHub user&#x27;s profile to decide how much to invest in their contributions? Christopher Trudeau is back on the show this week with 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>Quiz: Build a Tic-Tac-Toe Game With Python and Tkinter</title>
      <id>https://realpython.com/quizzes/tic-tac-toe-python/</id>
      <link href="https://realpython.com/quizzes/tic-tac-toe-python/"/>
      <updated>2026-05-22T12:00:00+00:00</updated>
      <summary>Test your Tkinter skills by building a tic-tac-toe game with widgets, event handling, layouts, and the model-view-controller pattern in Python.</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/tic-tac-toe-python/&quot;&gt;Build a Tic-Tac-Toe Game With Python and Tkinter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to design game logic with Python classes, lay out and update Tkinter widgets, and wire up button clicks to a handler through the event 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>Quiz: Context Managers and Using Python&#x27;s with Statement</title>
      <id>https://realpython.com/quizzes/with-statement-python/</id>
      <link href="https://realpython.com/quizzes/with-statement-python/"/>
      <updated>2026-05-21T12:00:00+00:00</updated>
      <summary>Check what you know about Python&#x27;s with statement and context managers, from built-ins like open() and threading.Lock to writing your own.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test what you learned in the video course &lt;a href=&quot;https://realpython.com/courses/with-statement-python/&quot;&gt;Context Managers and Using Python&amp;rsquo;s with Statement&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how the &lt;code&gt;with&lt;/code&gt; statement runs setup and teardown for you, how to use standard-library context managers like &lt;code&gt;open()&lt;/code&gt;, and how to write your own context managers as classes or with the &lt;code&gt;@contextmanager&lt;/code&gt; decorator.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Use the Claude API in Python</title>
      <id>https://realpython.com/claude-api-python/</id>
      <link href="https://realpython.com/claude-api-python/"/>
      <updated>2026-05-20T14:00:00+00:00</updated>
      <summary>Learn how to use the Claude API in Python to send prompts, control responses with system instructions, and get structured JSON output.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The fastest way to use the Claude API in Python is to install &lt;code&gt;anthropic&lt;/code&gt;, set your API key, and call &lt;code&gt;client.messages.create()&lt;/code&gt;. You’ll have a working response in under a minute:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/How_to_Use_the_Claude_API_in_Python_for_AI-Powered_Applications_-_screenshot.019ec0681f37.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/How_to_Use_the_Claude_API_in_Python_for_AI-Powered_Applications_-_screenshot.019ec0681f37.png&quot; width=&quot;1822&quot; height=&quot;1320&quot; srcset=&quot;/cdn-cgi/image/width=455,format=auto/https://files.realpython.com/media/How_to_Use_the_Claude_API_in_Python_for_AI-Powered_Applications_-_screenshot.019ec0681f37.png 455w, /cdn-cgi/image/width=607,format=auto/https://files.realpython.com/media/How_to_Use_the_Claude_API_in_Python_for_AI-Powered_Applications_-_screenshot.019ec0681f37.png 607w, /cdn-cgi/image/width=911,format=auto/https://files.realpython.com/media/How_to_Use_the_Claude_API_in_Python_for_AI-Powered_Applications_-_screenshot.019ec0681f37.png 911w, /cdn-cgi/image/width=1822,format=auto/https://files.realpython.com/media/How_to_Use_the_Claude_API_in_Python_for_AI-Powered_Applications_-_screenshot.019ec0681f37.png 1822w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;How to Use the Claude API in Python for AI-Powered Applications&quot; data-asset=&quot;6887&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Example of Using the Claude API in Python&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a href=&quot;/ref/ai-coding-tools/claude/&quot; class=&quot;ref-link&quot;&gt;Claude&lt;/a&gt; is Anthropic’s &lt;a href=&quot;/ref/ai-coding-glossary/llm/&quot; class=&quot;ref-link&quot;&gt;large language model&lt;/a&gt;, accessible via a clean &lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;REST API&lt;/a&gt; with an official Python SDK. Unlike heavier AI frameworks that require you to wire up multiple components before you see any output, the &lt;code&gt;anthropic&lt;/code&gt; package gets you to a working response in a handful of lines.&lt;/p&gt;
&lt;p&gt;In the following steps, you’ll install the &lt;code&gt;anthropic&lt;/code&gt; SDK, call Claude from Python, shape Claude’s behavior with a &lt;a href=&quot;/ref/ai-coding-glossary/system-prompt/&quot; class=&quot;ref-link&quot;&gt;system prompt&lt;/a&gt;, and then return structured &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;JSON&lt;/a&gt; output using a schema or &lt;a href=&quot;https://realpython.com/python-pydantic/&quot;&gt;Pydantic&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Claude’s responses are non-deterministic, so the same prompt produces different output each time, which is expected for a large language model. Also, API calls cost money based on the number of &lt;a href=&quot;/ref/ai-coding-glossary/token/&quot; class=&quot;ref-link&quot;&gt;tokens&lt;/a&gt; processed. Keep an eye on your usage in the Claude Console as you follow along.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Each step builds on the last, and the final script is short enough to read in one sitting but complete enough to extend into a real application of your own.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/claude-api-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-claude-api-python-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use the Claude API 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.a032542568e1.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 Use the Claude API 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/claude-api-python/&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: #abe5b2;&quot; alt=&quot;Two people at a service counter labeled Claude API, where a robot behind the window prints out a long paper response, with a Python logo on the counter.&quot; src=&quot;https://files.realpython.com/media/How-to-Use-the-Claude-API-in-Python-for-AI-Powered-Applications_Watermarked.2bd1f7ed4e48.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-Use-the-Claude-API-in-Python-for-AI-Powered-Applications_Watermarked.2bd1f7ed4e48.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Use-the-Claude-API-in-Python-for-AI-Powered-Applications_Watermarked.2bd1f7ed4e48.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Use-the-Claude-API-in-Python-for-AI-Powered-Applications_Watermarked.2bd1f7ed4e48.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Use-the-Claude-API-in-Python-for-AI-Powered-Applications_Watermarked.2bd1f7ed4e48.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.a032542568e1.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/claude-api-python/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Use the Claude API in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of using the Claude API in Python. Send prompts, set system instructions, and return structured JSON with a schema.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before diving in, make sure you have the following in place:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python knowledge:&lt;/strong&gt; You should be comfortable with Python basics, like &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;defining functions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;running scripts&lt;/a&gt; from the terminal, and working with &lt;a href=&quot;/ref/glossary/virtual-environment/&quot; class=&quot;ref-link&quot;&gt;virtual environments&lt;/a&gt;. If virtual environments are new to you, &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;Python Virtual Environments: A Primer&lt;/a&gt; has you covered before you continue.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 3.9 or higher:&lt;/strong&gt; The &lt;code&gt;anthropic&lt;/code&gt; SDK requires Python 3.9 as a minimum. If you’re not sure which version you have, run &lt;code&gt;python --version&lt;/code&gt; in your terminal. If you need to install or upgrade, follow the steps in the &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;guide on installing Python&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;An Anthropic account:&lt;/strong&gt; You’ll need an Anthropic account to generate an API key in the Claude Console. Step 1 will show you how to find and secure your key once you’re in.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Don’t worry if you’ve never worked with an &lt;a href=&quot;/ref/glossary/api/&quot; class=&quot;ref-link&quot;&gt;API&lt;/a&gt; before. This tutorial will walk you through authentication and help you make your first request from scratch.&lt;/p&gt;
&lt;h2 id=&quot;step-1-set-up-the-claude-api-in-python&quot;&gt;Step 1: Set Up the Claude API in Python&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-set-up-the-claude-api-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you can call Claude from Python, you need an API key and the &lt;code&gt;anthropic&lt;/code&gt; package installed. By the end of this step, you’ll have both, and Claude will be responding to your first prompt.&lt;/p&gt;
&lt;h3 id=&quot;get-your-api-key-and-install-anthropic&quot;&gt;Get Your API Key and Install &lt;code&gt;anthropic&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#get-your-api-key-and-install-anthropic&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Log in to the &lt;a href=&quot;https://console.anthropic.com/&quot;&gt;Claude Console&lt;/a&gt; or create a new account. If you’re starting fresh, you can begin using the API after adding $5 of credits.&lt;/p&gt;
&lt;p&gt;Then navigate to the API Keys section. Click &lt;em&gt;Create Key&lt;/em&gt;, give it a descriptive name like &lt;code&gt;real-python-tutorial&lt;/code&gt;, and copy it immediately. You won’t see it again after you close the dialog.&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; Never paste your API key directly into your code. Instead, store it as an &lt;a href=&quot;/ref/stdlib/os/&quot; class=&quot;ref-link&quot;&gt;environment variable&lt;/a&gt;. The &lt;code&gt;anthropic&lt;/code&gt; SDK automatically reads it from &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; at runtime, so you never need to reference it explicitly in your scripts.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Storing your key as an environment variable means it never touches your source code or version control history. The exact command depends on your operating system:&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.a032542568e1.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.a032542568e1.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.a032542568e1.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;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;powershell&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&gt;PowerShell Script&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;codeblock__contents&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;PS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$env:ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;your-api-key-here&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&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;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;&lt;span class=&quot;nb&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;your-api-key-here&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With your API key stored safely, you’re ready to install the SDK. Create a fresh virtual environment and activate it before installing anything. This isolation prevents the &lt;code&gt;anthropic&lt;/code&gt; package from conflicting with your system-level tools.&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.a032542568e1.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.a032542568e1.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.a032542568e1.svg#v4--apple&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-2&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-2&quot; role=&quot;tabpanel&quot;&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;powershell&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&gt;PowerShell Script&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;codeblock__contents&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;PS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;python&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Scripts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;activate&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;python&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pip&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anthropic&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-macos-tab-2&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-macos-2&quot; role=&quot;tabpanel&quot;&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv/
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv/bin/activate
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;anthropic
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;send-your-first-prompt&quot;&gt;Send Your First Prompt&lt;a class=&quot;headerlink&quot; href=&quot;#send-your-first-prompt&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/claude-api-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/claude-api-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: How to Use the Claude API in Python</title>
      <id>https://realpython.com/quizzes/claude-api-python/</id>
      <link href="https://realpython.com/quizzes/claude-api-python/"/>
      <updated>2026-05-20T12:00:00+00:00</updated>
      <summary>Test your understanding of using the Claude API in Python. Send prompts, set system instructions, and return structured JSON with a schema.</summary>
      <content type="html">
        &lt;p&gt;In this quiz, you&amp;rsquo;ll test your knowledge of &lt;a href=&quot;https://realpython.com/claude-api-python/&quot;&gt;How to Use the Claude API in Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to install the &lt;code&gt;anthropic&lt;/code&gt; SDK, send prompts to Claude with &lt;code&gt;client.messages.create()&lt;/code&gt;, shape responses with a system parameter, and return structured JSON output using a schema or Pydantic.&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>Tapping Into the Zen of Python</title>
      <id>https://realpython.com/courses/tapping-into-the-zen-of-python/</id>
      <link href="https://realpython.com/courses/tapping-into-the-zen-of-python/"/>
      <updated>2026-05-19T14:00:00+00:00</updated>
      <summary>Explore the Zen of Python and its 19 guiding principles for writing readable, practical code. Learn its history, jokes, and meaning.</summary>
      <content type="html">
        &lt;p&gt;The &lt;strong&gt;Zen of Python&lt;/strong&gt; is a collection of 19 aphorisms that capture the guiding principles behind Python&amp;rsquo;s design. You can display them anytime by running &lt;code&gt;import this&lt;/code&gt; in a Python REPL. Tim Peters wrote them in 1999 as a joke, but they became an iconic part of Python culture that was even formalized as &lt;a href=&quot;/ref/glossary/pep/&quot; class=&quot;ref-link&quot;&gt;PEP&lt;/a&gt; 20.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll understand:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Zen of Python is a &lt;strong&gt;humorous poem&lt;/strong&gt; of 19 aphorisms describing Python&amp;rsquo;s design philosophy&lt;/li&gt;
&lt;li&gt;Running &lt;code&gt;import this&lt;/code&gt; in a Python &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt; displays the &lt;strong&gt;complete text&lt;/strong&gt; of the Zen of Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tim Peters&lt;/strong&gt; wrote the Zen of Python in 1999 as a tongue-in-cheek comment on a mailing list&lt;/li&gt;
&lt;li&gt;The aphorisms are &lt;strong&gt;guidelines, not strict rules&lt;/strong&gt;, and some intentionally contradict each other&lt;/li&gt;
&lt;li&gt;The principles promote &lt;strong&gt;readability, simplicity, and explicitness&lt;/strong&gt; while acknowledging that practicality matters&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Experienced Pythonistas often refer to the Zen of Python as a source of wisdom and guidance, especially when they want to settle an argument about certain design decisions in a piece of code. In this video course, you&amp;rsquo;ll explore the origins of the Zen of Python, learn how to interpret its mysterious aphorisms, and discover the Easter eggs hidden within it.&lt;/p&gt;
&lt;p&gt;You don&amp;rsquo;t need to be a Python master to understand the Zen of Python! But you do need to answer an important question: &lt;strong&gt;What exactly is the Zen of Python?&lt;/strong&gt;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: Tapping Into the Zen of Python</title>
      <id>https://realpython.com/quizzes/tapping-into-the-zen-of-python/</id>
      <link href="https://realpython.com/quizzes/tapping-into-the-zen-of-python/"/>
      <updated>2026-05-19T12:00:00+00:00</updated>
      <summary>Test your understanding of the Zen of Python, its 19 guiding aphorisms, their origins, and how to balance them when writing real-world 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/courses/tapping-into-the-zen-of-python/&quot;&gt;Tapping Into the Zen of Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the origins of the poem, the meaning of several aphorisms, and the inside jokes hidden throughout.&lt;/p&gt;
&lt;p&gt;The questions explore how the principles apply in practice and when it&amp;rsquo;s okay to bend the rules in the name of practicality.&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: Absolute vs Relative Imports in Python</title>
      <id>https://realpython.com/quizzes/absolute-vs-relative-python-imports/</id>
      <link href="https://realpython.com/quizzes/absolute-vs-relative-python-imports/"/>
      <updated>2026-05-19T12:00:00+00:00</updated>
      <summary>Test your understanding of absolute and relative imports in Python, and learn the syntax, styling, and trade-offs of each approach.</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/absolute-vs-relative-python-imports/&quot;&gt;Absolute vs Relative Imports in Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how Python&amp;rsquo;s import system resolves modules, the differences between absolute and relative imports, and the PEP 8 conventions for styling import statements.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Built-in Functions: A Complete Guide</title>
      <id>https://realpython.com/python-built-in-functions/</id>
      <link href="https://realpython.com/python-built-in-functions/"/>
      <updated>2026-05-18T14:00:00+00:00</updated>
      <summary>Use Python&#x27;s built-in functions for math, data types, iterables, and I/O to write shorter, more Pythonic code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s &lt;strong&gt;built-in functions&lt;/strong&gt; are predefined functions you can use anywhere in your code without any imports. They handle common tasks across math, data type creation, iterable processing, and input and output. Knowing which ones to reach for makes your code shorter and more &lt;strong&gt;Pythonic&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Recognize Python’s &lt;strong&gt;built-in functions&lt;/strong&gt; and the &lt;strong&gt;built-in scope&lt;/strong&gt; they live in&lt;/li&gt;
&lt;li&gt;Use the right built-in for &lt;strong&gt;math&lt;/strong&gt;, &lt;strong&gt;data types&lt;/strong&gt;, &lt;strong&gt;iterables&lt;/strong&gt;, and &lt;strong&gt;I/O&lt;/strong&gt; tasks&lt;/li&gt;
&lt;li&gt;Tell apart true functions and &lt;strong&gt;classes&lt;/strong&gt; that look like functions&lt;/li&gt;
&lt;li&gt;Apply built-ins to solve &lt;strong&gt;practical problems&lt;/strong&gt; without reinventing the wheel&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you’ll need to be familiar with Python programming, including topics like working with built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data types&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/primer-on-python-decorators/&quot;&gt;decorators&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/&quot;&gt;scopes&lt;/a&gt;, and the &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;import&lt;/a&gt; system.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-built-in-functions-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-built-in-functions-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use Python’s built-in functions.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get the PDF Guide:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-built-in-functions-cheatsheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-built-in-functions-cheatsheet&quot; markdown&gt;Click here to download&lt;/a&gt; a free PDF guide that gives you a complete overview of Python’s built-in functions and how to use them.&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.a032542568e1.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 Built-in Functions: A Complete Guide” 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-built-in-functions/&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: #ff7e74;&quot; alt=&quot;Python&#x27;s Built-in Functions: A Complete Exploration&quot; src=&quot;https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.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-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Pythons-Built-in-Functions-A-Quick-Exploration_Watermarked.44a8e102943b.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.a032542568e1.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-built-in-functions/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python Built-in Functions: A Complete Guide&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of Python&#x27;s built-in functions for math, data types, iterables, and I/O—and when to reach for each one.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;built-in-functions-in-python&quot;&gt;Built-in Functions in Python&lt;a class=&quot;headerlink&quot; href=&quot;#built-in-functions-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python has several &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt; available for you to use directly from anywhere in your code. These functions are known as &lt;a href=&quot;https://docs.python.org/3/library/functions.html&quot;&gt;built-in functions&lt;/a&gt; and they cover many common programming problems, from mathematical computations to Python-specific features.&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; All these functions live in the &lt;a href=&quot;https://docs.python.org/3/library/builtins.html&quot;&gt;&lt;code&gt;builtins&lt;/code&gt;&lt;/a&gt; module, which Python loads at startup and exposes through the built-in scope, so you can use them anywhere without importing the module. Importing the module explicitly is useful if you know that you’ll shadow a built-in name with one of your own variables or functions. Doing so keeps the original within reach as &lt;code&gt;builtins.name&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Among these built-ins, you’ll also find classes with function-style names like &lt;a href=&quot;/ref/builtin-types/str/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;str&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;/ref/builtin-types/tuple/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;tuple&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;/ref/builtin-types/list/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;list&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;/ref/builtin-types/dict/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;dict&lt;/code&gt;&lt;/a&gt;, which define built-in data types. These classes are listed in the Python documentation as &lt;em&gt;built-in functions&lt;/em&gt;, so they’re covered in this tutorial too.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In this tutorial, you’ll learn the basics of Python’s built-in functions. By the end, you’ll know what their use cases are and how they work. You’ll start with the built-in functions for math computations.&lt;/p&gt;
&lt;h2 id=&quot;using-math-related-built-in-functions&quot;&gt;Using Math-Related Built-in Functions&lt;a class=&quot;headerlink&quot; href=&quot;#using-math-related-built-in-functions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python, you’ll find a few built-in functions that take care of common math operations, like computing the absolute value of a &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt;, calculating powers, and more. Here’s a summary of the math-related built-in functions in Python:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-absolute-value/&quot;&gt;&lt;code&gt;abs()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Calculates the absolute value of a number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://docs.python.org/3/library/functions.html#divmod&quot;&gt;&lt;code&gt;divmod()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Computes the quotient and remainder of integer division&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-min-and-max/&quot;&gt;&lt;code&gt;max()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Finds the largest of the given arguments or items in an iterable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-min-and-max/&quot;&gt;&lt;code&gt;min()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Finds the smallest of the given arguments or items in an iterable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://docs.python.org/3/library/functions.html#pow&quot;&gt;&lt;code&gt;pow()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Raises a number to a power&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-rounding/#pythons-built-in-round-function&quot;&gt;&lt;code&gt;round()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Rounds a floating-point value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-sum-function/&quot;&gt;&lt;code&gt;sum()&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Sums the values in an iterable&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;In the following sections, you’ll learn how these functions work and how to use them in your Python code.&lt;/p&gt;
&lt;h3 id=&quot;getting-the-absolute-value-of-a-number-abs&quot;&gt;Getting the Absolute Value of a Number: &lt;code&gt;abs()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#getting-the-absolute-value-of-a-number-abs&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Absolute_value&quot;&gt;absolute value&lt;/a&gt; or &lt;strong&gt;modulus&lt;/strong&gt; of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Real_number&quot;&gt;real number&lt;/a&gt; is its non-negative value. In other words, the absolute value is the number without its &lt;a href=&quot;https://en.wikipedia.org/wiki/Sign_(mathematics)&quot;&gt;sign&lt;/a&gt;. For example, the absolute value of &lt;em&gt;-5&lt;/em&gt; is &lt;em&gt;5&lt;/em&gt;, and the absolute value of &lt;em&gt;5&lt;/em&gt; is also &lt;em&gt;5&lt;/em&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To learn more about &lt;code&gt;abs()&lt;/code&gt;, check out the &lt;a href=&quot;https://realpython.com/python-absolute-value/&quot;&gt;How to Find an Absolute Value in Python&lt;/a&gt; tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Python’s built-in &lt;code&gt;abs()&lt;/code&gt; function allows you to quickly compute the absolute value of a &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt;. Here’s its signature:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;python_syntax&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&gt;Python Syntax&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;codeblock__contents&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;nb&quot;&gt;abs&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;/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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;The &lt;code&gt;number&lt;/code&gt; argument can be any numeric value, including integers, floating-point numbers, complex numbers, fractions, and decimals. Take a look at a few examples:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;decimal&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;Decimal&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;fractions&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;Fraction&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;abs&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;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42&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;abs&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;mf&quot;&gt;42.42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42.42&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;42.42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42.42&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;complex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-2+3j&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3.605551275463989&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;complex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2+3j&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3.605551275463989&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fraction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-1/2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Fraction(1, 2)&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fraction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1/2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Fraction(1, 2)&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;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Decimal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-0.5&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Decimal(&#x27;0.5&#x27;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Decimal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0.5&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Decimal(&#x27;0.5&#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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;In these examples, you compute the absolute value of different numeric types using the &lt;code&gt;abs()&lt;/code&gt; function. First, you use integer numbers, then floating-point and complex numbers, and finally, fractional and decimal numbers. In all cases, when you call the function with a negative value, the final result removes the sign.&lt;/p&gt;
&lt;p&gt;For a practical example, say that you need to compute the total profits and losses of your company from a month’s transactions:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;transactions&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;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;300&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;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&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;incomes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;income&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;income&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transactions&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;income&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expenses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expense&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expense&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transactions&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expense&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;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;Total incomes: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;incomes&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;Total incomes: $800&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;Total expenses: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expenses&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;Total expenses: $300&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;Total profit: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;incomes&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expenses&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;Total profit: $500&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-built-in-functions/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-built-in-functions/ »&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 #295: Agentic Architecture: Why Files Aren&#x27;t Always Enough</title>
      <id>https://realpython.com/podcasts/rpp/295/</id>
      <link href="https://realpython.com/podcasts/rpp/295/"/>
      <updated>2026-05-15T12:00:00+00:00</updated>
      <summary>What are the limitations of using a file-based agent workflow? Why do massive context windows tend to collapse? This week on the show, Mikiko Bazeley from MongoDB joins us to discuss agentic architecture and context engineering.</summary>
      <content type="html">
        &lt;p&gt;What are the limitations of using a file-based agent workflow? Why do massive context windows tend to collapse? This week on the show, Mikiko Bazeley from MongoDB joins us to discuss agentic architecture and context engineering.&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 Array: Working With Numeric Data Efficiently</title>
      <id>https://realpython.com/quizzes/python-array/</id>
      <link href="https://realpython.com/quizzes/python-array/"/>
      <updated>2026-05-15T12:00:00+00:00</updated>
      <summary>Test your understanding of Python&#x27;s array module: type codes, the buffer protocol, mutable sequence behavior, and trade-offs with lists.</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-array/&quot;&gt;Python&amp;rsquo;s Array: Working With Numeric Data Efficiently&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the differences between Python&amp;rsquo;s &lt;code&gt;array&lt;/code&gt; module and the built-in &lt;code&gt;list&lt;/code&gt;, the meaning of type codes, how to create and manipulate arrays as mutable sequences, and the performance trade-offs of using a low-level numeric container.&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: Cursor vs Windsurf: Which AI Code Editor Is Best for Python?</title>
      <id>https://realpython.com/quizzes/cursor-vs-windsurf-python/</id>
      <link href="https://realpython.com/quizzes/cursor-vs-windsurf-python/"/>
      <updated>2026-05-14T12:00:00+00:00</updated>
      <summary>Test your understanding of how Cursor and Windsurf compare for Python across AI completion, agentic edits, and debugging workflows.</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/cursor-vs-windsurf-python/&quot;&gt;Cursor vs Windsurf: Which AI Code Editor Is Best for Python?&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By working through these questions, you&amp;rsquo;ll revisit how the two editors differ across code completion, agentic multi-file editing, and debugging.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll also reconnect with the audit points worth applying whenever an AI agent writes Python on your behalf.&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 Metaclasses</title>
      <id>https://realpython.com/quizzes/python-metaclasses/</id>
      <link href="https://realpython.com/quizzes/python-metaclasses/"/>
      <updated>2026-05-14T12:00:00+00:00</updated>
      <summary>Check how well you understand Python metaclasses, from what they are and how type creates classes to when a custom metaclass is actually the right tool.</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-metaclasses/&quot;&gt;Python Metaclasses&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Metaclasses sit behind every class you write in Python, and they&amp;rsquo;re one of the language&amp;rsquo;s deeper object-oriented concepts. By working through this quiz, you&amp;rsquo;ll revisit how classes are themselves objects, how &lt;code&gt;type&lt;/code&gt; creates them, and how a custom metaclass lets you customize class creation.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll also reflect on when a custom metaclass is actually the right tool and when a simpler technique does the job better.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Use OpenCode for AI-Assisted Python Coding</title>
      <id>https://realpython.com/opencode-guide/</id>
      <link href="https://realpython.com/opencode-guide/"/>
      <updated>2026-05-13T14:00:00+00:00</updated>
      <summary>Learn how to use OpenCode, an open-source AI coding assistant, with a free Gemini API key to analyze and refactor Python code in your terminal.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;OpenCode is an open-source AI coding agent that runs in your terminal and lets you analyze and refactor a Python project through conversational commands. In this guide, you’ll install it on your system, set it up with a free Google Gemini API key, and learn the basics of how to use it in your daily programming work.&lt;/p&gt;
&lt;p&gt;Here’s what OpenCode’s main interface looks like:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/opencode-initial-screen.7b04d0286d62.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/opencode-initial-screen.7b04d0286d62.png&quot; width=&quot;2048&quot; height=&quot;1152&quot; srcset=&quot;/cdn-cgi/image/width=512,format=auto/https://files.realpython.com/media/opencode-initial-screen.7b04d0286d62.png 512w, /cdn-cgi/image/width=682,format=auto/https://files.realpython.com/media/opencode-initial-screen.7b04d0286d62.png 682w, /cdn-cgi/image/width=1024,format=auto/https://files.realpython.com/media/opencode-initial-screen.7b04d0286d62.png 1024w, /cdn-cgi/image/width=2048,format=auto/https://files.realpython.com/media/opencode-initial-screen.7b04d0286d62.png 2048w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;OpenCode&#x27;s Initial Screen&quot; data-asset=&quot;6837&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;OpenCode&#x27;s Initial Screen&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a href=&quot;/ref/ai-coding-tools/opencode/&quot; class=&quot;ref-link&quot;&gt;OpenCode&lt;/a&gt; works as a conversational assistant you explicitly direct. Ask it to analyze functions, refactor code, or explain issues. Press &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt; to send your query, and you’ll get a response with full awareness of your project context. It supports more than seventy-five AI providers, including Anthropic, OpenAI, and &lt;a href=&quot;/ref/ai-coding-tools/gemini/&quot; class=&quot;ref-link&quot;&gt;Google Gemini&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you’re a Python developer who prefers working in the terminal, OpenCode offers deliberate, context-aware assistance and a customizable &lt;code&gt;AGENTS.md&lt;/code&gt; configuration file.&lt;/p&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.a032542568e1.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 Use OpenCode for AI-Assisted Python Coding” 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/opencode-guide/&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: #abe5b2;&quot; alt=&quot;A person in a hard hat and safety goggles with a clipboard stands beside a wall of panels labeled OpenCode, Analyze, Refactor, AI Models, Python Projects, LSP, Git UI, and Modes (Plan/Build).&quot; src=&quot;https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.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-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.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.a032542568e1.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/opencode-guide/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Use OpenCode for AI-Assisted Python Coding&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Quiz yourself on OpenCode: install it, connect an AI provider, and use it to analyze and refactor Python from your terminal.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you start working with OpenCode, you’ll need to fulfill the following prerequisites regarding your current system and working environment:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Python 3.11 or higher for the sample project&lt;/li&gt;
&lt;li&gt;A modern terminal emulator&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You also need an &lt;strong&gt;AI provider account&lt;/strong&gt;. In this guide, you’ll use &lt;a href=&quot;https://aistudio.google.com&quot;&gt;Google AI Studio&lt;/a&gt; to get a free Gemini &lt;a href=&quot;/ref/glossary/api/&quot; class=&quot;ref-link&quot;&gt;API&lt;/a&gt; key. The free Gemini tier lets you follow along without any additional costs. However, you can also use Anthropic, OpenAI, or &lt;a href=&quot;https://realpython.com/github-copilot-python/&quot;&gt;GitHub Copilot&lt;/a&gt; if you already have subscriptions to those services.&lt;/p&gt;
&lt;p&gt;This guide uses a sample project consisting of a dice-rolling script. You’ll find the full &lt;a href=&quot;/ref/glossary/source-code/&quot; class=&quot;ref-link&quot;&gt;source code&lt;/a&gt; in a collapsible block at the start of Step 2. The download below includes the starting script and the final refactored version so you can compare your work when you’re done:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/opencode-guide-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-opencode-guide-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; you’ll use to learn about AI-assisted Python coding with OpenCode.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You’ll also need some background knowledge of &lt;a href=&quot;https://realpython.com/python-first-steps/&quot;&gt;Python programming&lt;/a&gt; and basic experience with your operating system’s &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal or command line&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;step-1-install-and-set-up-opencode&quot;&gt;Step 1: Install and Set Up OpenCode&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-install-and-set-up-opencode&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It’s time to install OpenCode and get it talking to a model. You’ll install the tool on your system, authenticate with Gemini using a free API key, configure a default model, and verify that OpenCode responds correctly to your Python questions before you start coding with it.&lt;/p&gt;
&lt;h3 id=&quot;install-and-launch-opencode&quot;&gt;Install and Launch OpenCode&lt;a class=&quot;headerlink&quot; href=&quot;#install-and-launch-opencode&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The quickest way to install OpenCode is to use the official installation script, which you can do with the following command:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;-fsSL&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;https://opencode.ai/install&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;bash
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;This script detects your platform, downloads the appropriate binary, installs the tool, and adds it to your &lt;a href=&quot;https://realpython.com/add-python-to-path/&quot;&gt;&lt;code&gt;PATH&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you prefer a package manager, you can also install OpenCode with Homebrew on macOS or Linux:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;brew&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;anomalyco/tap/opencode
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;Note that the Homebrew team maintains the official formula and updates it less frequently than the installation script above.&lt;/p&gt;
&lt;p&gt;Alternatively, you can install it as a &lt;a href=&quot;https://nodejs.org/en&quot;&gt;Node.js&lt;/a&gt; package using &lt;a href=&quot;https://www.npmjs.com/&quot;&gt;&lt;code&gt;npm&lt;/code&gt;&lt;/a&gt; if you already have this tool on your system:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;npm&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-g&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;opencode-ai
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;If you’re on &lt;a href=&quot;https://opencode.ai/docs/windows-wsl&quot;&gt;Windows&lt;/a&gt;, the best experience comes from using WSL (Windows Subsystem for Linux). Set up WSL first by following &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/wsl/install&quot;&gt;Microsoft’s WSL installation guide&lt;/a&gt;, then open a WSL terminal and run the &lt;code&gt;curl&lt;/code&gt; command above. For optimal performance, you should store your project within the WSL filesystem rather than on a Windows drive.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/opencode-guide/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/opencode-guide/ »&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 Type-Safe LLM Agents With Pydantic AI</title>
      <id>https://realpython.com/courses/building-type-safe-llm-agents-with-pydantic-ai/</id>
      <link href="https://realpython.com/courses/building-type-safe-llm-agents-with-pydantic-ai/"/>
      <updated>2026-05-12T14:00:00+00:00</updated>
      <summary>Build type-safe LLM agents in Python with Pydantic AI using structured outputs, function calling, and dependency injection.</summary>
      <content type="html">
        &lt;p&gt;Pydantic AI is a Python framework for building LLM agents that return validated, structured outputs using Pydantic models. Instead of parsing raw strings from LLMs, you get type-safe objects with automatic validation.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;ve used FastAPI or Pydantic before, then you&amp;rsquo;ll recognize the familiar pattern of defining schemas with type hints and letting the framework handle the type validation for you.&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;&lt;strong&gt;Pydantic AI&lt;/strong&gt; uses &lt;code&gt;BaseModel&lt;/code&gt; classes to define structured outputs that guarantee &lt;strong&gt;type safety&lt;/strong&gt; and automatic &lt;strong&gt;validation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;@agent.tool&lt;/code&gt; &lt;strong&gt;decorator&lt;/strong&gt; registers Python functions that &lt;strong&gt;LLMs can invoke&lt;/strong&gt; based on user queries and docstrings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dependency injection&lt;/strong&gt; with &lt;code&gt;deps_type&lt;/code&gt; provides &lt;strong&gt;type-safe&lt;/strong&gt; runtime context like database connections without using &lt;strong&gt;global state&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validation retries&lt;/strong&gt; automatically rerun queries when the LLM returns invalid data, which increases &lt;strong&gt;reliability&lt;/strong&gt; but also &lt;strong&gt;API costs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Google Gemini&lt;/strong&gt;, &lt;strong&gt;OpenAI&lt;/strong&gt;, and &lt;strong&gt;Anthropic&lt;/strong&gt; models support structured outputs best, while other providers have &lt;strong&gt;varying capabilities&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: Building Type-Safe LLM Agents With Pydantic AI</title>
      <id>https://realpython.com/quizzes/pydantic-ai-video/</id>
      <link href="https://realpython.com/quizzes/pydantic-ai-video/"/>
      <updated>2026-05-12T12:00:00+00:00</updated>
      <summary>Test what you&#x27;ve learned about building type-safe LLM agents in Python with Pydantic AI: structured outputs, tools, and dependency injection.</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/courses/building-type-safe-llm-agents-with-pydantic-ai/&quot;&gt;Building Type-Safe LLM Agents With Pydantic AI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how Pydantic AI returns structured outputs from LLMs, how validation retries improve reliability, how tools and function calling work, how dependency injection flows through &lt;code&gt;RunContext&lt;/code&gt;, and what trade-offs to expect when running agents in production.&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: The LEGB Rule &amp; Understanding Python Scope</title>
      <id>https://realpython.com/quizzes/legb-rule-python-scope/</id>
      <link href="https://realpython.com/quizzes/legb-rule-python-scope/"/>
      <updated>2026-05-12T12:00:00+00:00</updated>
      <summary>Test your understanding of Python scope, the LEGB rule, and how Python resolves names across local, enclosing, global, and built-in scopes.</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/courses/legb-rule-python-scope/&quot;&gt;The LEGB Rule &amp;amp; Understanding Python Scope&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how Python resolves names using the LEGB rule, what the local, enclosing, global, and built-in scopes look like in practice, and how the &lt;code&gt;global&lt;/code&gt; and &lt;code&gt;nonlocal&lt;/code&gt; statements let you reach across scope boundaries.&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 Flatten a List of Lists in Python</title>
      <id>https://realpython.com/python-flatten-list/</id>
      <link href="https://realpython.com/python-flatten-list/"/>
      <updated>2026-05-11T14:00:00+00:00</updated>
      <summary>Learn how to flatten a list of lists in Python using for loops, list comprehensions, itertools, functools, NumPy, and recursion.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Flattening a list in Python involves converting a nested list structure into a single, one-dimensional list. A common approach to flatten a list of lists is to use a &lt;code&gt;for&lt;/code&gt; loop to iterate through each sublist. Then you can add each item to a new list with the &lt;code&gt;.extend()&lt;/code&gt; method or the augmented concatenation operator (&lt;code&gt;+=&lt;/code&gt;). This will “unlist” the list, resulting in a flattened list.&lt;/p&gt;
&lt;p&gt;Python’s standard library offers other tools to achieve similar results. You can also use a list comprehension for a concise one-liner solution. Each method has its own performance characteristics, but &lt;code&gt;for&lt;/code&gt; loops and list comprehensions are generally more efficient.&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;Flattening a list&lt;/strong&gt; involves converting nested lists into a single list.&lt;/li&gt;
&lt;li&gt;You can use a &lt;strong&gt;&lt;code&gt;for&lt;/code&gt; loop and &lt;code&gt;.extend()&lt;/code&gt;&lt;/strong&gt; or a &lt;strong&gt;list comprehension&lt;/strong&gt; to flatten lists in Python.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Standard-library functions&lt;/strong&gt; like &lt;code&gt;itertools.chain()&lt;/code&gt; and &lt;code&gt;functools.reduce()&lt;/code&gt; can also flatten lists.&lt;/li&gt;
&lt;li&gt;A custom &lt;strong&gt;&lt;code&gt;flatten()&lt;/code&gt;&lt;/strong&gt; function, either recursive or iterative, handles arbitrarily nested lists.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;.flatten()&lt;/code&gt; method in NumPy&lt;/strong&gt; efficiently flattens arrays for data science tasks.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To better illustrate what it means to flatten a list, say that you have the following matrix of numeric values:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;matrix&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;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&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;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;The &lt;code&gt;matrix&lt;/code&gt; variable holds a Python &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;list&lt;/a&gt; that contains four nested lists. Each nested list represents a row in the matrix. The rows store four items or numbers each. Now say that you want to turn this matrix into the following list:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;codeblock__contents&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;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;How do you manage to flatten your matrix and get a one-dimensional list like the one above? In this tutorial, you’ll learn how to do that in Python.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-flatten-list-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-flatten-list-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that showcases and compares several ways to flatten a list of lists 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.a032542568e1.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 Flatten a List of Lists 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-flatten-list/&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: #aae4b1;&quot; alt=&quot;How to Flatten a List of Lists in Python&quot; src=&quot;https://files.realpython.com/media/How-to-Flatten-a-List-of-Lists_Watermarked.2f9407737589.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-Flatten-a-List-of-Lists_Watermarked.2f9407737589.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Flatten-a-List-of-Lists_Watermarked.2f9407737589.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Flatten-a-List-of-Lists_Watermarked.2f9407737589.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Flatten-a-List-of-Lists_Watermarked.2f9407737589.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.a032542568e1.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-flatten-list/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Flatten a List of Lists in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of how to flatten a list of lists in Python using for loops, list comprehensions, itertools, recursion, and NumPy.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;how-to-flatten-a-list-of-lists-with-a-for-loop&quot;&gt;How to Flatten a List of Lists With a &lt;code&gt;for&lt;/code&gt; Loop&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-flatten-a-list-of-lists-with-a-for-loop&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;How can you flatten a list of lists in Python? In general, to flatten a list of lists, you can run the following steps either explicitly or implicitly:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Create&lt;/strong&gt; a new empty list to store the &lt;strong&gt;flattened data&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Iterate&lt;/strong&gt; over each &lt;strong&gt;nested list&lt;/strong&gt; or sublist in the original list.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add&lt;/strong&gt; every &lt;strong&gt;item&lt;/strong&gt; from the current sublist to the list of flattened data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Return&lt;/strong&gt; the resulting list with the &lt;strong&gt;flattened data&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can follow several paths and use multiple tools to run these steps in Python. The most natural and readable way to do this is to use a &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/a&gt;, which allows you to explicitly iterate over the sublists.&lt;/p&gt;
&lt;p&gt;Then you need a way to add items to the new flattened list. For that, you have a couple of valid options. First, you’ll turn to the &lt;code&gt;.extend()&lt;/code&gt; method from the &lt;code&gt;list&lt;/code&gt; class itself, and then you’ll give the &lt;a href=&quot;https://realpython.com/python-assignment-operator/#augmented-assignments-for-concatenation-and-repetition&quot;&gt;augmented concatenation operator&lt;/a&gt; (&lt;code&gt;+=&lt;/code&gt;) a go.&lt;/p&gt;
&lt;p&gt;To continue with the &lt;code&gt;matrix&lt;/code&gt; example, here’s how you would translate these steps into Python code using a &lt;code&gt;for&lt;/code&gt; loop and the &lt;code&gt;.extend()&lt;/code&gt; method:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten_extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matrix&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;flat_list&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;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matrix&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;flat_list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flat_list&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;Inside &lt;code&gt;flatten_extend()&lt;/code&gt;, you first create a new empty list called &lt;code&gt;flat_list&lt;/code&gt;. You’ll use this list to store the flattened data when you extract it from &lt;code&gt;matrix&lt;/code&gt;. Then you start a loop to iterate over the inner, or nested, lists from &lt;code&gt;matrix&lt;/code&gt;. In this example, you use the name &lt;code&gt;row&lt;/code&gt; to represent the current nested list.&lt;/p&gt;
&lt;p&gt;In every iteration, you use &lt;code&gt;.extend()&lt;/code&gt; to add the content of the current sublist to &lt;code&gt;flat_list&lt;/code&gt;. This method takes an &lt;a href=&quot;https://realpython.com/python-iterators-iterables/&quot;&gt;iterable&lt;/a&gt; as an &lt;a href=&quot;/ref/glossary/argument/&quot; class=&quot;ref-link&quot;&gt;argument&lt;/a&gt; and appends its items to the end of the target list.&lt;/p&gt;
&lt;p&gt;Now go ahead and run the following code to check that your &lt;a href=&quot;/ref/glossary/function/&quot; class=&quot;ref-link&quot;&gt;function&lt;/a&gt; does the job:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;flatten_extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[9, 3, 8, 3, 4, 5, 2, 8, 6, 4, 3, 1, 1, 0, 4, 5]&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;That’s neat! You’ve flattened your first list of lists. As a result, you have a one-dimensional list containing all the numeric values from &lt;code&gt;matrix&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;.extend()&lt;/code&gt;, you’ve come up with a Pythonic and readable way to flatten your lists. You can get the same result using the &lt;a href=&quot;https://realpython.com/python-assignment-operator/#augmented-assignments-for-concatenation-and-repetition&quot;&gt;augmented concatenation operator&lt;/a&gt; (&lt;code&gt;+=&lt;/code&gt;) on your &lt;code&gt;flat_list&lt;/code&gt; object. However, this alternative approach may not be as readable:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten_concatenation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matrix&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;flat_list&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;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;flat_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flat_list&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-flatten-list/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-flatten-list/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #294: Declarative Charts in Python &amp; Discerning Iterators vs Iterables</title>
      <id>https://realpython.com/podcasts/rpp/294/</id>
      <link href="https://realpython.com/podcasts/rpp/294/"/>
      <updated>2026-05-08T12:00:00+00:00</updated>
      <summary>What if you could build charts in Python by describing what your data means, instead of scripting every visual detail? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What if you could build charts in Python by describing what your data means, instead of scripting every visual detail? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>ChatterBot: Build a Chatbot With Python</title>
      <id>https://realpython.com/build-a-chatbot-python-chatterbot/</id>
      <link href="https://realpython.com/build-a-chatbot-python-chatterbot/"/>
      <updated>2026-05-06T14:00:00+00:00</updated>
      <summary>Build a Python chatbot with the ChatterBot library. Clean real conversation data, train on custom datasets, and add local AI with Ollama.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The Python ChatterBot library lets you build a self-learning command-line chatbot with just a few lines of code. You’ll set up a basic bot, clean real WhatsApp conversation data with regular expressions, and train your chatbot on that custom corpus. You’ll also plug in a local LLM through Ollama to augment its replies with contextual knowledge.&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;ChatterBot is a &lt;strong&gt;Python library&lt;/strong&gt; that combines text processing, machine learning, and a local database to generate chatbot replies.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;minimal ChatterBot script&lt;/strong&gt; instantiates &lt;code&gt;ChatBot&lt;/code&gt;, collects user input in a loop, and returns matching responses through &lt;code&gt;.get_response()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Training with &lt;code&gt;ListTrainer&lt;/code&gt; and default settings stores conversation pairs in a &lt;strong&gt;SQLite&lt;/strong&gt; database that ChatterBot queries with &lt;strong&gt;Levenshtein distance&lt;/strong&gt; to pick each reply.&lt;/li&gt;
&lt;li&gt;ChatterBot can call a &lt;strong&gt;local LLM&lt;/strong&gt; through &lt;code&gt;OllamaLogicAdapter&lt;/code&gt;, voting against other logic adapters with a confidence score.&lt;/li&gt;
&lt;li&gt;ChatterBot was &lt;strong&gt;revived in 2025&lt;/strong&gt; with spaCy-based &lt;a href=&quot;/ref/ai-coding-glossary/nlp/&quot; class=&quot;ref-link&quot;&gt;NLP&lt;/a&gt;, CSV and JSON trainers, and experimental &lt;a href=&quot;/ref/ai-coding-glossary/llm/&quot; class=&quot;ref-link&quot;&gt;LLM&lt;/a&gt; support.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you’ll move from a potted plant that can only echo &lt;em&gt;hello&lt;/em&gt; to a chatbot that chats knowledgeably about houseplants. You can follow along with your own WhatsApp export or grab the provided sample data below.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-a-chatbot-python-chatterbot-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-a-chatbot-python-chatterbot-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to build a chatbot with Python’s Chatterbot.&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.a032542568e1.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 “ChatterBot: Build a Chatbot With 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/build-a-chatbot-python-chatterbot/&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: #ffc774;&quot; alt=&quot;ChatterBot: Build a Chatbot With Python&quot; src=&quot;https://files.realpython.com/media/Chatterbot-Build-a-Chatbot-With-Python_Watermarked.07a26197ef70.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Chatterbot-Build-a-Chatbot-With-Python_Watermarked.07a26197ef70.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Chatterbot-Build-a-Chatbot-With-Python_Watermarked.07a26197ef70.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Chatterbot-Build-a-Chatbot-With-Python_Watermarked.07a26197ef70.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Chatterbot-Build-a-Chatbot-With-Python_Watermarked.07a26197ef70.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.a032542568e1.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/build-a-chatbot-python-chatterbot/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;ChatterBot: Build a Chatbot With Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of the ChatterBot Python library, from training a basic bot with ListTrainer to wiring in a local LLM through Ollama.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;preview-the-chatbot&quot;&gt;Preview the Chatbot&lt;a class=&quot;headerlink&quot; href=&quot;#preview-the-chatbot&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;At the end of this tutorial, you’ll have a command-line chatbot that can respond to your inputs with semi-meaningful replies:&lt;/p&gt;
&lt;div&gt;





&lt;div class=&quot;embed-responsive rounded mb-3 bg-light&quot; style=&quot;aspect-ratio: 3840/2160;&quot;&gt;
  &lt;video-player&gt;
    &lt;video-skin&gt;

        &lt;hls-video src=&quot;https://stream.realpython.com/01e4ee90-0fef-4099-bdbc-50785a2a3bc4/playlist.m3u8&quot; poster=&quot;https://stream.realpython.com/01e4ee90-0fef-4099-bdbc-50785a2a3bc4/thumbnail.jpg&quot; preload=&quot;metadata&quot; playsinline&gt;
          &lt;track default kind=&quot;metadata&quot; label=&quot;thumbnails&quot; src=&quot;/video-thumbnails/f182c5b4-8efc-4bce-86e1-85106691734a.vtt&quot;&gt;
        &lt;/track&gt;&lt;/hls-video&gt;

    &lt;/video-skin&gt;
  &lt;/video-player&gt;
&lt;/div&gt;



&lt;/div&gt;

&lt;p&gt;You’ll achieve that by preparing WhatsApp chat data and using it to train the chatbot. Beyond learning from your automated training, the chatbot will improve over time as it gets more exposure to questions and replies from user interactions.&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.chatterbot.us/&quot;&gt;The ChatterBot library&lt;/a&gt; combines text processing, &lt;a href=&quot;/ref/ai-coding-glossary/machine-learning/&quot; class=&quot;ref-link&quot;&gt;machine learning&lt;/a&gt; algorithms, and data storage and retrieval to allow you to build flexible chatbots.&lt;/p&gt;
&lt;p&gt;You can build an industry-specific chatbot by training it with relevant data. Additionally, the chatbot will remember user responses and continue building its internal &lt;a href=&quot;https://en.wikipedia.org/wiki/Graph_(abstract_data_type)&quot;&gt;graph structure&lt;/a&gt; to improve the responses that it can give.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; After a long hiatus, ChatterBot was revived in early 2025 with support for modern Python, new training formats for &lt;a href=&quot;https://realpython.com/python-csv/&quot;&gt;CSV&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;JSON&lt;/a&gt; data, and even experimental LLM integration. Under the hood, ChatterBot now uses &lt;a href=&quot;https://spacy.io/&quot;&gt;spaCy&lt;/a&gt; for language processing, which gives it a more robust &lt;a href=&quot;https://realpython.com/natural-language-processing-spacy-python/&quot;&gt;NLP pipeline&lt;/a&gt; than before.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you want to develop an LLM-first chatbot, Real Python’s LLM Application Development With Python learning path takes you through the concepts and libraries step by step:&lt;/p&gt;
&lt;div&gt;


&lt;learning-path-card data-path-id=&quot;llm-application-development-python&quot; class=&quot;d-block container border rounded mb-4 shadow-sm&quot; data-progress-card&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 px-3&quot;&gt;

        &lt;a href=&quot;/learning-paths/llm-application-development-python/&quot; aria-hidden=&quot;true&quot; tabindex=&quot;-1&quot; data-not-previewable&gt;&lt;img loading=&quot;lazy&quot; src=&quot;https://files.realpython.com/media/LLM-Application-Development-With-Python_Watermarked.b05c360e7536.jpg&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/LLM-Application-Development-With-Python_Watermarked.b05c360e7536.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/LLM-Application-Development-With-Python_Watermarked.b05c360e7536.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/LLM-Application-Development-With-Python_Watermarked.b05c360e7536.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/LLM-Application-Development-With-Python_Watermarked.b05c360e7536.jpg 1920w&quot; style=&quot;background: #fe7e73;&quot; class=&quot;rounded img-fluid w-100 my-0&quot; alt=&quot;Two people operating a large machine with conveyor belts and panels labeled RAG, Agents, and MCP, alongside a robotic arm, a Python logo, and API key icons.&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;/a&gt;

    &lt;/div&gt;
    &lt;div class=&quot;col px-3 pl-sm-0 mt-3 mt-sm-0&quot;&gt;
      &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Learning Path&lt;/strong&gt;&lt;/p&gt;
      &lt;a class=&quot;stretched-link&quot; href=&quot;/learning-paths/llm-application-development-python/&quot;&gt;&lt;h2 class=&quot;my-0 h3&quot;&gt;LLM Application Development With Python&lt;/h2&gt;&lt;/a&gt;
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;13 Resources ⋅ &lt;strong&gt;Skills:&lt;/strong&gt; OpenAI, Ollama, OpenRouter, Prompt Engineering, LangChain, LlamaIndex, ChromaDB, MarkItDown, RAG, Embeddings, Pydantic AI, LangGraph, MCP&lt;/p&gt;


      &lt;div class=&quot;progress mt-2&quot; data-progress-placeholder&gt;
        &lt;div class=&quot;progress-bar bg-light text-black-50 small w-100&quot; data-progress-placeholder-bar&gt;&lt;/div&gt;
      &lt;/div&gt;


      &lt;div class=&quot;progress mt-2 d-none&quot; data-progress-container&gt;
        &lt;div class=&quot;progress-bar small&quot; role=&quot;progressbar&quot; data-progress-bar aria-valuenow=&quot;0&quot; aria-valuemin=&quot;0&quot; aria-valuemax=&quot;100&quot; style=&quot;min-width: 2.5em; cursor: default;&quot;&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/learning-path-card&gt;
&lt;/div&gt;

&lt;p&gt;In this tutorial, you’ll start with an untrained chatbot that’ll showcase how quickly you can create an interactive chatbot using Python’s ChatterBot. You’ll also notice how small the vocabulary of an untrained chatbot is.&lt;/p&gt;
&lt;p&gt;Next, you’ll learn how you can train such a chatbot and check on the slightly improved results. The more plentiful and high-quality your training data is, the better your chatbot’s responses will be.&lt;/p&gt;
&lt;p&gt;Therefore, you’ll either fetch the conversation history of one of your WhatsApp chats or use the provided &lt;code&gt;chat.txt&lt;/code&gt; file that you can download here:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/build-a-chatbot-python-chatterbot-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-build-a-chatbot-python-chatterbot-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to build a chatbot with Python’s Chatterbot.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;It’s rare that input data comes exactly in the form you need, so you’ll clean the chat export data to get it into a useful input format. This process will show you some tools you can use for data cleaning, which may help you prepare other input data to feed to your chatbot.&lt;/p&gt;
&lt;p&gt;After data cleaning, you’ll retrain your chatbot and give it another spin to experience the improved performance. Finally, you’ll hook a local LLM into your chatbot to augment the variety and contextual relevance of its responses.&lt;/p&gt;
&lt;p&gt;When you work through this process from start to finish, you’ll get a good idea of how you can build and train a Python chatbot with the ChatterBot library so that it can provide an interactive experience with relevant replies.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you get started, make sure that you have &lt;strong&gt;Python 3.10 or later&lt;/strong&gt; installed, which is the minimum Python version that ChatterBot supports. If you need help setting up Python, check out &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;Python 3 Installation &amp;amp; Setup Guide&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/build-a-chatbot-python-chatterbot/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/build-a-chatbot-python-chatterbot/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Use Codex CLI to Enhance Your Python Projects</title>
      <id>https://realpython.com/courses/use-codex-cli-enhance-your-python-projects/</id>
      <link href="https://realpython.com/courses/use-codex-cli-enhance-your-python-projects/"/>
      <updated>2026-05-05T14:00:00+00:00</updated>
      <summary>Learn how to use Codex CLI to add features to Python projects directly from your terminal, without needing a browser or IDE plugins.</summary>
      <content type="html">
        &lt;p&gt;After watching this video course, you&amp;rsquo;ll be able to use Codex CLI to add features to a Python project directly from your terminal. &lt;strong&gt;Codex CLI&lt;/strong&gt; is an AI-powered coding assistant that runs inside your terminal. It understands your project structure, reads your files, and proposes multi-file changes using natural language instructions.&lt;/p&gt;
&lt;p&gt;Instead of copying code from a browser or relying on an IDE plugin, you&amp;rsquo;ll use Codex CLI to implement a real feature in a multi-file Python project directly from your terminal.&lt;/p&gt;
&lt;p&gt;In the following lessons, you&amp;rsquo;ll install and configure Codex CLI, use it to implement a deletion feature in a contact book app, and then refine that feature through iterative prompting.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>A New Python Packaging Council and Other News for May 2026</title>
      <id>https://realpython.com/python-news-may-2026/</id>
      <link href="https://realpython.com/python-news-may-2026/"/>
      <updated>2026-05-04T14:00:00+00:00</updated>
      <summary>A new Python Packaging Council, PEP 803 stabilizes the free-threaded ABI, the incremental GC gets reverted, and Astral changes hands.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;April gave Python developers a new governing body. &lt;a href=&quot;https://peps.python.org/pep-0772/&quot;&gt;PEP 772&lt;/a&gt; was accepted on April 16, creating a dedicated &lt;strong&gt;Python Packaging Council&lt;/strong&gt; that will make binding decisions about packaging standards and tools. After years of informal coordination through the Python Packaging Authority (PyPA), the packaging community now has its own elected five-member council with authority comparable to the &lt;a href=&quot;/ref/glossary/python-steering-council/&quot; class=&quot;ref-link&quot;&gt;Steering Council&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On the release side, &lt;strong&gt;Python 3.15.0 alpha 8&lt;/strong&gt; dropped with a refreshed &lt;a href=&quot;/ref/glossary/jit-compiler/&quot; class=&quot;ref-link&quot;&gt;JIT&lt;/a&gt; delivering &lt;strong&gt;6–7 percent speedups on x86-64 Linux&lt;/strong&gt; and &lt;strong&gt;12–13 percent on AArch64 macOS&lt;/strong&gt;. The core team also decided to &lt;strong&gt;revert 3.14’s incremental garbage collector&lt;/strong&gt; after production reports of runaway memory use, with the fix landing in the upcoming 3.14.5 patch release. The next pre-release is the first beta, scheduled for &lt;strong&gt;May 5&lt;/strong&gt;, which marks the feature freeze for Python 3.15.&lt;/p&gt;
&lt;p&gt;Elsewhere, Google released the open-weights &lt;strong&gt;Gemma 4&lt;/strong&gt; family, &lt;strong&gt;Starlette 1.0&lt;/strong&gt; shipped for FastAPI’s foundation, and the broader Python ecosystem absorbed the news that &lt;strong&gt;OpenAI acquired Astral&lt;/strong&gt;, the company behind &lt;code&gt;uv&lt;/code&gt;, Ruff, and ty. Get ready to dig into the biggest Python news from the past month!&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Join Now:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/newsletter/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-newsletter&quot; markdown&gt;Click here to join the Real Python Newsletter&lt;/a&gt; and you’ll never miss another Python tutorial, course, or news update.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;python-releases-and-pep-highlights&quot;&gt;Python Releases and PEP Highlights&lt;a class=&quot;headerlink&quot; href=&quot;#python-releases-and-pep-highlights&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;April pushed Python 3.15 to its final alpha before the beta freeze, walked back the incremental garbage collector introduced in 3.14, and gave the Steering Council a busy month of PEP decisions. The packaging community even got its own elected governing body for the first time. Plenty to unpack on the language and process side of the ecosystem.&lt;/p&gt;
&lt;h3 id=&quot;python-3150-alpha-8-final-alpha-before-beta-freeze&quot;&gt;Python 3.15.0 Alpha 8: Final Alpha Before Beta Freeze&lt;a class=&quot;headerlink&quot; href=&quot;#python-3150-alpha-8-final-alpha-before-beta-freeze&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://blog.python.org/2026/04/python-3150a8-3144-31313/&quot;&gt;Python 3.15.0a8&lt;/a&gt; landed on April 7, released alongside maintenance updates &lt;strong&gt;3.14.4&lt;/strong&gt; and &lt;strong&gt;3.13.13&lt;/strong&gt;. Release manager Hugo van Kemenade confirmed that a8 is the &lt;strong&gt;final alpha&lt;/strong&gt; before the beta phase begins. If you maintain a library, this is the last alpha where you can file an issue against an unreleased feature and reasonably expect it to land before the freeze.&lt;/p&gt;
&lt;p&gt;Alpha 8 consolidates a long list of &lt;a href=&quot;/ref/glossary/pep/&quot; class=&quot;ref-link&quot;&gt;PEPs&lt;/a&gt; you’ve been hearing about in earlier alphas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0810/&quot;&gt;PEP 810&lt;/a&gt;: Explicit lazy imports, which we covered &lt;a href=&quot;https://realpython.com/python-news-april-2026/#python-3150-alpha-7-lazy-imports-land&quot;&gt;last month&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0814/&quot;&gt;PEP 814&lt;/a&gt;: &lt;code&gt;frozendict&lt;/code&gt; as a built-in type&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0799/&quot;&gt;PEP 799&lt;/a&gt;: Statistical sampling profiler&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0798/&quot;&gt;PEP 798&lt;/a&gt;: Unpacking in comprehensions&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0686/&quot;&gt;PEP 686&lt;/a&gt;: UTF-8 as the default encoding&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://peps.python.org/pep-0728/&quot;&gt;PEP 728&lt;/a&gt;: TypedDict enhancements&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The headline number is the &lt;a href=&quot;/ref/glossary/jit-compiler/&quot; class=&quot;ref-link&quot;&gt;JIT&lt;/a&gt; performance jump. On x86-64 Linux, the alpha reports a &lt;strong&gt;6–7 percent geometric mean improvement&lt;/strong&gt; over the standard &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt;. On AArch64 macOS, the gain is &lt;strong&gt;12–13 percent&lt;/strong&gt; over the tail-calling interpreter introduced in 3.14. Those aren’t microbenchmark curiosities. They’re cumulative gains across a broad suite of workloads.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you haven’t tried the alpha yet, installing it in an isolated environment is a good idea. Running &lt;code&gt;uv python install 3.15.0a8&lt;/code&gt; pulls the binary, and &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;pyenv&lt;/a&gt; handles alpha builds too. The next pre-release, &lt;strong&gt;3.15.0 beta 1&lt;/strong&gt;, is scheduled for &lt;strong&gt;May 5&lt;/strong&gt;, which marks the feature freeze. After that, no new PEPs land in 3.15.&lt;/p&gt;
&lt;/div&gt;
&lt;h3 id=&quot;incremental-gc-reverted-in-3145-and-315&quot;&gt;Incremental GC Reverted in 3.14.5 and 3.15&lt;a class=&quot;headerlink&quot; href=&quot;#incremental-gc-reverted-in-3145-and-315&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;On April 16, release manager Hugo van Kemenade &lt;a href=&quot;https://discuss.python.org/t/reverting-the-incremental-gc-in-python-3-14-and-3-15/107014&quot;&gt;proposed reverting&lt;/a&gt; the incremental &lt;a href=&quot;/ref/glossary/garbage-collection/&quot; class=&quot;ref-link&quot;&gt;garbage collector&lt;/a&gt; that debuted in Python 3.14, and the core team agreed. The revert will ship in &lt;strong&gt;Python 3.14.5&lt;/strong&gt; and also make it into 3.15 before feature freeze.&lt;/p&gt;
&lt;p&gt;The reasoning is practical. Neil Schemenauer’s testing on production workloads showed that the incremental collector cut maximum pause times from &lt;strong&gt;26 ms down to 1.3 ms&lt;/strong&gt;, which looks great on paper. But peak memory usage climbed to as much as &lt;strong&gt;5x&lt;/strong&gt; the generational baseline in the worst case, and total runtime went up, not down, because of the extra bookkeeping.&lt;/p&gt;
&lt;p&gt;For most Python programs, like web apps, data pipelines, and batch jobs, reducing long pauses isn’t the win that matters. Memory pressure is.&lt;/p&gt;
&lt;p&gt;The unusual part is doing this in a patch release. The working assumption during 3.14’s release cycle was that the incremental GC had earned its place. Rolling it back in 3.14.5 is a reminder that “passed the benchmark suite” and “works in production” aren’t the same thing. If you noticed your 3.14 deployments using noticeably more memory than 3.13, this is almost certainly why, and 3.14.5 should give you the old behavior back.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The incremental approach isn’t dead. The core team noted that it could return in Python 3.16 through a proper &lt;a href=&quot;https://peps.python.org/&quot;&gt;PEP&lt;/a&gt; review process, which the original implementation had skipped. If you were on the fence about the switch, waiting for the formal design round is probably the right call.&lt;/p&gt;
&lt;/div&gt;
&lt;h3 id=&quot;pep-772-accepted-python-gets-a-packaging-council&quot;&gt;PEP 772 Accepted: Python Gets a Packaging Council&lt;a class=&quot;headerlink&quot; href=&quot;#pep-772-accepted-python-gets-a-packaging-council&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;On April 16, the &lt;a href=&quot;/ref/glossary/psf/&quot; class=&quot;ref-link&quot;&gt;Python Software Foundation (PSF)&lt;/a&gt; and the Steering Council accepted &lt;a href=&quot;https://peps.python.org/pep-0772/&quot;&gt;PEP 772&lt;/a&gt;, which creates a &lt;strong&gt;five-member Packaging Council&lt;/strong&gt; with broad authority over packaging standards, tools, and implementations. It’s one of the biggest governance changes the ecosystem has seen since the Steering Council itself was established back in 2019.&lt;/p&gt;
&lt;p&gt;Council members will be &lt;strong&gt;elected by PSF voting members&lt;/strong&gt; who opt into the election. The council runs on staggered two-year terms, with two seats and three seats rotating in different cycles to preserve institutional continuity. Decision-making emphasizes &lt;strong&gt;consensus over voting&lt;/strong&gt;, following the same pattern that has worked for the Steering Council.&lt;/p&gt;
&lt;p&gt;The practical impact is that a formal, elected body now owns decisions about tools like &lt;a href=&quot;/ref/glossary/pip/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;, &lt;code&gt;setuptools&lt;/code&gt;, and &lt;a href=&quot;https://realpython.com/pypi-publish-python-package/&quot;&gt;PyPI&lt;/a&gt;, replacing the ambiguous delegation model defined in PEP 609.&lt;/p&gt;
&lt;p&gt;If you’ve ever wondered why packaging decisions in Python sometimes feel stuck in committee, PEP 772 is the structural answer to that complaint. It also sets the stage for the council to weigh in on &lt;a href=&quot;/ref/ai-coding-glossary/llm/&quot; class=&quot;ref-link&quot;&gt;LLM&lt;/a&gt;-era packaging concerns, which are popping up faster than the PyPA’s informal coordination could address them.&lt;/p&gt;
&lt;h3 id=&quot;pep-803-accepted-stable-abi-goes-free-threaded&quot;&gt;PEP 803 Accepted: Stable ABI Goes Free-Threaded&lt;a class=&quot;headerlink&quot; href=&quot;#pep-803-accepted-stable-abi-goes-free-threaded&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://peps.python.org/pep-0803/&quot;&gt;PEP 803&lt;/a&gt; was accepted on March 30 and targets Python 3.15. It defines &lt;strong&gt;&lt;code&gt;abi3t&lt;/code&gt;&lt;/strong&gt;, a new variant of the stable ABI that works with free-threaded builds. When the Steering Council accepted &lt;a href=&quot;https://peps.python.org/pep-0779/&quot;&gt;PEP 779&lt;/a&gt; last year, it promised &lt;a href=&quot;https://realpython.com/python-news-july-2025/#python-314-beta-3-lands-free-threaded-support&quot;&gt;free-threading&lt;/a&gt; would get a proper stable ABI story for 3.15. PEP 803 is that follow-through.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-may-2026/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-may-2026/ »&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 #293: Agentic Data Science Pair Programming With marimo pair</title>
      <id>https://realpython.com/podcasts/rpp/293/</id>
      <link href="https://realpython.com/podcasts/rpp/293/"/>
      <updated>2026-05-01T12:00:00+00:00</updated>
      <summary>How do you add agent skills to your data science workflow? How can a coding agent assist with data wrangling and research? This week on the show, Trevor Manz from marimo joins us to discuss marimo pair.</summary>
      <content type="html">
        &lt;p&gt;How do you add agent skills to your data science workflow? How can a coding agent assist with data wrangling and research? This week on the show, Trevor Manz from marimo joins us to discuss marimo pair.&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>AI Coding Agents Guide: A Map of the Four Workflow Types</title>
      <id>https://realpython.com/ai-coding-agents-guide/</id>
      <link href="https://realpython.com/ai-coding-agents-guide/"/>
      <updated>2026-04-29T14:00:00+00:00</updated>
      <summary>AI coding agents come in four types: IDE, terminal, PR, and cloud. Learn how each workflow fits into modern Python development.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;AI coding agents can read your code, reason about changes, and act on your behalf. To choose the right one, it helps to understand the four common workflow types: integrated development environment (IDE), terminal, pull request (PR), and cloud.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Identify&lt;/strong&gt; the four common &lt;strong&gt;agent interaction modes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Understand&lt;/strong&gt; what makes &lt;strong&gt;each workflow distinct&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recognize&lt;/strong&gt; which mode fits &lt;strong&gt;common development scenarios&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Weigh&lt;/strong&gt; the &lt;strong&gt;risks and tradeoffs&lt;/strong&gt; of each workflow&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before exploring the four workflow types, it’s worth looking at what makes a coding tool &lt;a href=&quot;/ref/ai-coding-glossary/agentic-coding/&quot; class=&quot;ref-link&quot;&gt;agentic&lt;/a&gt; in the first place.&lt;/p&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.a032542568e1.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 “AI Coding Agents Guide: A Map of the Four Workflow Types” 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/ai-coding-agents-guide/&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;A person in overalls pointing at a four-piece puzzle map labeled IDE, Cloud, CLI, and PR/Repo, with a map info legend beside it and a Python logo.&quot; src=&quot;https://files.realpython.com/media/A-Practical-Map-of-Types-of-AI-Coding-Agents_Watermarked.7955cfd5f864.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/A-Practical-Map-of-Types-of-AI-Coding-Agents_Watermarked.7955cfd5f864.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/A-Practical-Map-of-Types-of-AI-Coding-Agents_Watermarked.7955cfd5f864.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/A-Practical-Map-of-Types-of-AI-Coding-Agents_Watermarked.7955cfd5f864.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/A-Practical-Map-of-Types-of-AI-Coding-Agents_Watermarked.7955cfd5f864.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.a032542568e1.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/ai-coding-agents-guide/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;AI Coding Agents Guide: A Map of the Four Workflow Types&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Check your understanding of how AI coding agents fit into your workflow through four interaction modes: IDE, terminal, pull request, and cloud.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Cheat Sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/ai-coding-agents-guide-cheatsheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-ai-coding-agents-guide-cheatsheet&quot; markdown&gt;Click here to download your free AI coding agents cheat sheet&lt;/a&gt; and keep the four workflow types at your fingertips when choosing the right agent for the job.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;understanding-ai-coding-agents&quot;&gt;Understanding AI Coding Agents&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-ai-coding-agents&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While standard chatbots provide one-off answers, coding agents are designed for autonomy, operating through a continuous execution loop to solve complex tasks. This loop typically follows four distinct steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Read&lt;/strong&gt;: They read relevant files from your codebase to form their context.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reason&lt;/strong&gt;: They determine the logical steps needed to achieve your goal.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Act&lt;/strong&gt;: They execute those steps by editing files, running terminal commands, or using external tools.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Evaluate&lt;/strong&gt;: They check the results of their actions to see if more work is needed.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This loop repeats until the task is completed or the agent hands control back to you. Unlike simple predictive text or one-off prompts, agents bridge the gap between suggestion and execution by autonomously navigating the development workflow.&lt;/p&gt;
&lt;p&gt;The core agent loop will generally stay the same, but where an agent runs will shape how you interact with it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;In an editor&lt;/strong&gt;, it works alongside you.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;In a terminal&lt;/strong&gt;, you guide it step by step.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;In pull requests&lt;/strong&gt;, it reviews changes asynchronously.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;In the cloud&lt;/strong&gt;, it works in a managed environment and reports back later.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These environments define four primary agent types, each enabling a distinct workflow: &lt;strong&gt;IDE agents&lt;/strong&gt;, &lt;strong&gt;terminal agents&lt;/strong&gt;, &lt;strong&gt;PR agents&lt;/strong&gt;, and &lt;strong&gt;cloud agents&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;exploring-the-four-workflow-types&quot;&gt;Exploring the Four Workflow Types&lt;a class=&quot;headerlink&quot; href=&quot;#exploring-the-four-workflow-types&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The four workflow types describe interaction modes and don’t always map cleanly to product categories. The same tool often spans multiple workflows. For example, &lt;a href=&quot;/ref/ai-coding-tools/claude-code/&quot; class=&quot;ref-link&quot;&gt;Claude Code&lt;/a&gt; runs in your &lt;a href=&quot;https://code.claude.com/docs/en/overview#terminal&quot;&gt;terminal&lt;/a&gt;, in your &lt;a href=&quot;https://code.claude.com/docs/en/overview#vs-code&quot;&gt;editor&lt;/a&gt;, and in the cloud with &lt;a href=&quot;https://code.claude.com/docs/en/claude-code-on-the-web&quot;&gt;Claude Code on the web&lt;/a&gt;. It can also review pull requests with &lt;a href=&quot;https://code.claude.com/docs/en/code-review&quot;&gt;Code Review&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The goal is to match the workflow to the task. The diagram below summarizes the four types at a glance:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/Autonomous_Agent-2026-04-16-135819_2.0effa4a51d4b.jpeg&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/Autonomous_Agent-2026-04-16-135819_2.0effa4a51d4b.jpeg&quot; width=&quot;2943&quot; height=&quot;1000&quot; srcset=&quot;/cdn-cgi/image/width=735,format=auto/https://files.realpython.com/media/Autonomous_Agent-2026-04-16-135819_2.0effa4a51d4b.jpeg 735w, /cdn-cgi/image/width=981,format=auto/https://files.realpython.com/media/Autonomous_Agent-2026-04-16-135819_2.0effa4a51d4b.jpeg 981w, /cdn-cgi/image/width=1471,format=auto/https://files.realpython.com/media/Autonomous_Agent-2026-04-16-135819_2.0effa4a51d4b.jpeg 1471w, /cdn-cgi/image/width=2943,format=auto/https://files.realpython.com/media/Autonomous_Agent-2026-04-16-135819_2.0effa4a51d4b.jpeg 2943w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;AI Agent Workflow Type Table&quot; data-asset=&quot;6908&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;The Four Coding Agent Workflows&lt;/figcaption&gt;&lt;/figure&gt;

&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/ai-coding-agents-guide/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ai-coding-agents-guide/ »&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>Testing Your Code With Python&#x27;s unittest</title>
      <id>https://realpython.com/courses/testing-your-code-with-pythons-unittest/</id>
      <link href="https://realpython.com/courses/testing-your-code-with-pythons-unittest/"/>
      <updated>2026-04-28T14:00:00+00:00</updated>
      <summary>Learn how to use Python&#x27;s unittest framework to write unit tests for your code, including test cases, fixtures, and test suites.</summary>
      <content type="html">
        &lt;p&gt;The Python &lt;a href=&quot;https://docs.python.org/3/library/index.html&quot;&gt;standard library&lt;/a&gt; ships with a testing framework named &lt;strong&gt;&lt;code&gt;unittest&lt;/code&gt;&lt;/strong&gt;, which you can use to write automated tests for your code. The &lt;code&gt;unittest&lt;/code&gt; package has an object-oriented approach where test cases derive from a base class, which has several useful methods.&lt;/p&gt;
&lt;p&gt;The framework supports many features that will help you write consistent unit tests for your code. These features include test cases, fixtures, test suites, and test discovery capabilities.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write &lt;code&gt;unittest&lt;/code&gt; tests with the &lt;strong&gt;&lt;code&gt;TestCase&lt;/code&gt;&lt;/strong&gt; class&lt;/li&gt;
&lt;li&gt;Explore the &lt;strong&gt;assert&lt;/strong&gt; methods that &lt;code&gt;TestCase&lt;/code&gt; provides&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;unittest&lt;/code&gt; from the &lt;strong&gt;command line&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Group test cases using the &lt;strong&gt;&lt;code&gt;TestSuite&lt;/code&gt;&lt;/strong&gt; class&lt;/li&gt;
&lt;li&gt;Create &lt;strong&gt;fixtures&lt;/strong&gt; to handle &lt;strong&gt;setup&lt;/strong&gt; and &lt;strong&gt;teardown&lt;/strong&gt; logic&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this video course, you should be familiar with some important Python concepts, such as &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-assert-statement/&quot;&gt;assertions&lt;/a&gt;. Having a good understanding of code &lt;a href=&quot;https://realpython.com/python-testing/&quot;&gt;testing&lt;/a&gt; is a plus.&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 Conceptualize Python Fundamentals for Greater Mastery</title>
      <id>https://realpython.com/conceptualize-python-fundamentals/</id>
      <link href="https://realpython.com/conceptualize-python-fundamentals/"/>
      <updated>2026-04-27T14:00:00+00:00</updated>
      <summary>Master Python fundamentals by learning how to conceptualize core concepts like variables, loops, and functions for better understanding and retention.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Struggling to conceptualize Python fundamentals is a common problem learners face. If you’re unable to put a fundamental concept into perspective and form a clear mental picture of what it’s about, it’ll be difficult to understand and apply it.&lt;/p&gt;
&lt;p&gt;In this guide, you’ll walk through a framework of steps to help you better conceptualize Python fundamentals. This process is helpful for Python developers and learners at any experience level, but especially for beginners. If you are just starting out, this guide will help you build a solid understanding of the basics.&lt;/p&gt;
&lt;p&gt;You might want to set aside twenty minutes or so to read through the tutorial, and another thirty minutes to practice on a few key concepts. You should also gather a list of difficult topics, your preferred learning resources, and a note-taking app or pen and paper.&lt;/p&gt;
&lt;p&gt;Click the link below to download a free cheat sheet that covers the framework steps you’ll walk through in this guide:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Cheat Sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/conceptualize-python-fundamentals-cheatsheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-conceptualize-python-fundamentals-cheatsheet&quot; markdown&gt;Click here to download a free PDF&lt;/a&gt; that outlines the framework of steps for conceptualizing Python fundamentals.&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.a032542568e1.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 Conceptualize Python Fundamentals for Greater Mastery” 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/conceptualize-python-fundamentals/&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;A chef combining ingredients from labeled jars like Variables, Loops, and Lists into a pot, while a woman tastes the result, with a recipe board showing Define, Connect, and Apply steps.&quot; src=&quot;https://files.realpython.com/media/How-to-Conceptualize-Python-Fundamentals-for-Better-Understanding_Watermarked.4c4979cbf541.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-Conceptualize-Python-Fundamentals-for-Better-Understanding_Watermarked.4c4979cbf541.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Conceptualize-Python-Fundamentals-for-Better-Understanding_Watermarked.4c4979cbf541.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Conceptualize-Python-Fundamentals-for-Better-Understanding_Watermarked.4c4979cbf541.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Conceptualize-Python-Fundamentals-for-Better-Understanding_Watermarked.4c4979cbf541.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.a032542568e1.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/conceptualize-python-fundamentals/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Conceptualize Python Fundamentals for Greater Mastery&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Check your understanding of a framework for conceptualizing Python fundamentals, from defining concepts to comparing similar ideas.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;step-1-define-the-concept-in-your-own-words&quot;&gt;Step 1: Define the Concept in Your Own Words&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-define-the-concept-in-your-own-words&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Begin by briefly describing the concept in your own words. You can write your definition in the downloadable worksheet provided with this tutorial. Note that writing is a powerful tool for reinforcing learning, as educator and former Rutgers University professor Janet Emig asserted in her paper, &lt;a href=&quot;https://openlab.citytech.cuny.edu/fywpd/files/2019/01/emig-writing-as-a-mode-of-learning.pdf&quot;&gt;&lt;em&gt;Writing as a Mode of Learning&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;answer-key-questions-for-defining-a-concept&quot;&gt;Answer Key Questions for Defining a Concept&lt;a class=&quot;headerlink&quot; href=&quot;#answer-key-questions-for-defining-a-concept&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As a framework for your definition, consider these key questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What&lt;/strong&gt;: What is a short description of the concept?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Why&lt;/strong&gt;: Why is the concept important in the broader Python context?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How&lt;/strong&gt;: How is the concept used in a Python program?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These questions will help you establish a core understanding of the concept you’re learning.&lt;/p&gt;
&lt;p&gt;You might feel intimidated when you’re trying to define a Python concept. If you need help, there are many resources that can assist you. &lt;a href=&quot;https://realpython.com/ref/&quot;&gt;Real Python’s Reference section&lt;/a&gt; has concise definitions of Python keywords, built-in types, standard library modules, and more to help you build your own descriptions.&lt;/p&gt;
&lt;p&gt;If you’re a visual learner, using an illustration can be a powerful way to enhance your understanding. In addition to a written definition, you can draw a picture or diagram to illustrate the concept. For example, the &lt;a href=&quot;https://realpython.com/python-variables/#exploring-core-features-of-variables&quot;&gt;Variables in Python: Usage and Best Practices&lt;/a&gt; tutorial shows some example images of how you might picture variables. If you look at the &lt;a href=&quot;https://realpython.com/python-lists-tuples/#lists-and-tuples-can-be-indexed-and-sliced&quot;&gt;Lists vs Tuples in Python&lt;/a&gt; tutorial, you can see a diagram of a Python list.&lt;/p&gt;
&lt;p&gt;While pictures can be helpful, being able to conceptualize doesn’t necessarily mean you have to think visually. There are different thinking styles. &lt;a href=&quot;https://www.researchgate.net/publication/244250898_Verbal_or_Visual_Thinker_Different_Ways_of_Orienting_in_a_Complex_Picture&quot;&gt;Some researchers suggest&lt;/a&gt; that people can be visual or verbal thinkers. Pattern-based thinking is another style. Several of the tips in this tutorial encourage you to explore different aspects of these styles, depending on which works best for you.&lt;/p&gt;
&lt;h3 id=&quot;view-examples-of-concept-definitions&quot;&gt;View Examples of Concept Definitions&lt;a class=&quot;headerlink&quot; href=&quot;#view-examples-of-concept-definitions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You might find a couple of examples helpful in understanding how to define difficult concepts. Suppose you’re studying &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt;. Here are possible responses to the key questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What&lt;/strong&gt;: A variable is a name that points to an &lt;a href=&quot;/ref/glossary/object/&quot; class=&quot;ref-link&quot;&gt;object&lt;/a&gt; stored in the program’s memory.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Why&lt;/strong&gt;: Variables are key for data processing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How&lt;/strong&gt;: &lt;a href=&quot;/ref/glossary/assignment/&quot; class=&quot;ref-link&quot;&gt;Assigning&lt;/a&gt; a value to a variable using the &lt;a href=&quot;https://realpython.com/python-assignment-operator/&quot;&gt;assignment operator (&lt;code&gt;=&lt;/code&gt;)&lt;/a&gt; allows you to access your program’s data in a user-friendly way. You can then access and change the value by name throughout the program as needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This description provides a concise summary of what a variable is, why it matters, and how to use one. You can also include an example of variable usage as an addendum to your definition:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pycon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;age&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;
&lt;/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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;Here, you created a variable called &lt;code&gt;age&lt;/code&gt; and assigned it a value of 25. From now on, you can use the variable name &lt;code&gt;age&lt;/code&gt; to access, modify, or use the variable’s value.&lt;/p&gt;
&lt;p&gt;Or, you might be learning about &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;lists&lt;/a&gt;. Your definitions could look like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What&lt;/strong&gt;: A list is a &lt;a href=&quot;/ref/glossary/sequence/&quot; class=&quot;ref-link&quot;&gt;sequence&lt;/a&gt; of values or objects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Why&lt;/strong&gt;: Working with &lt;a href=&quot;https://realpython.com/python-sequences/&quot;&gt;sequences&lt;/a&gt; of items is a common, foundational task in programming. Python lists make this important work easier.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How&lt;/strong&gt;: You can create a list by writing a pair of square brackets, with a comma-separated sequence of items inside them. Assign the list to a variable to use it throughout your program.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here’s a short Python list that demonstrates the points in the definitions above:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/conceptualize-python-fundamentals/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/conceptualize-python-fundamentals/ »&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 #292: Becoming a Better Python Developer Through Learning Rust</title>
      <id>https://realpython.com/podcasts/rpp/292/</id>
      <link href="https://realpython.com/podcasts/rpp/292/"/>
      <updated>2026-04-24T12:00:00+00:00</updated>
      <summary>How can learning Rust help make you a better Python Developer? How do techniques required by a compiled language translate to improving your Python code? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How can learning Rust help make you a better Python Developer? How do techniques required by a compiled language translate to improving your Python code? Christopher Trudeau is back on the show this week with 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>Altair: Declarative Charts With Python</title>
      <id>https://realpython.com/altair-python/</id>
      <link href="https://realpython.com/altair-python/"/>
      <updated>2026-04-22T14:00:00+00:00</updated>
      <summary>Build interactive Python charts the declarative way with Altair. Map data to visual properties and add linked selections. No JavaScript required.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;There’s a moment many data analysts know well: you have a new dataset and a clear question, and you open a notebook only to find yourself writing boilerplate axis and figure setup before you’ve even looked at the data. Matplotlib gives you fine-grained control, but that control comes with a cost. Altair takes a completely different approach to data visualization in Python.&lt;/p&gt;
&lt;p&gt;Instead of scripting every visual detail, you describe &lt;em&gt;what&lt;/em&gt; your data means. This includes specifying which column goes on which axis, what should be colored, and what should be interactive. Altair then generates the visualization.&lt;/p&gt;
&lt;p&gt;If you’re wondering whether it’s worth adding another visualization library to your toolkit, here’s how Altair and Matplotlib compare:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;th class=&quot;text-center&quot;&gt;Pick Altair&lt;/th&gt;
&lt;th class=&quot;text-center&quot;&gt;Pick Matplotlib&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Interactive exploratory charts in notebooks&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;✅&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pixel-precise publication figures or 3D plots&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;—&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Altair generates &lt;strong&gt;web-native&lt;/strong&gt; charts. The output is HTML and JavaScript, which means charts render right in your notebook and can be saved as standalone HTML files or embedded in web pages. It’s not a replacement for Matplotlib, and it doesn’t try to be. Think of them as tools you reach for in different situations.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/altair-python-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-altair-python-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; you’ll use to build interactive Python charts the declarative way with Altair.&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.a032542568e1.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 “Altair: Declarative Charts With 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/altair-python/&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;Two people building a chart by inserting cards into a machine labeled Describe Your Chart, with a Python logo, colorful bar charts, and mapping steps displayed.&quot; src=&quot;https://files.realpython.com/media/Altair-Declarative-Charts-with-Python_Watermarked.f6d83ff116ed.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Altair-Declarative-Charts-with-Python_Watermarked.f6d83ff116ed.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Altair-Declarative-Charts-with-Python_Watermarked.f6d83ff116ed.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Altair-Declarative-Charts-with-Python_Watermarked.f6d83ff116ed.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Altair-Declarative-Charts-with-Python_Watermarked.f6d83ff116ed.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.a032542568e1.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/altair-python/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Altair: Declarative Charts With Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your knowledge of Altair, the declarative data visualization library for Python that turns DataFrames into interactive charts.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;start-using-altair-in-python&quot;&gt;Start Using Altair in Python&lt;a class=&quot;headerlink&quot; href=&quot;#start-using-altair-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It’s a good idea to install Altair in a dedicated &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt;. It pulls in several dependencies like &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt; and the Vega-Lite renderer, and a &lt;a href=&quot;/ref/glossary/virtual-environment/&quot; class=&quot;ref-link&quot;&gt;virtual environment&lt;/a&gt; keeps them from interfering with your other projects. Create one and install Altair with &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;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;altair-venv
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;altair-venv/bin/activate
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(altair-venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;altair
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;This tutorial uses Python 3.14 and Altair 6.0. All the code runs inside a &lt;a href=&quot;https://realpython.com/jupyter-notebook-introduction/&quot;&gt;Jupyter notebook&lt;/a&gt;, which is the most common environment for interactive data exploration with Altair. If you prefer a different JavaScript-capable environment like &lt;a href=&quot;/ref/code-editors-ides/visual-studio-code/&quot; class=&quot;ref-link&quot;&gt;VS Code&lt;/a&gt;, &lt;a href=&quot;/ref/tools/google-colab/&quot; class=&quot;ref-link&quot;&gt;Google Colab&lt;/a&gt;, or &lt;a href=&quot;/ref/code-editors-ides/jupyterlab/&quot; class=&quot;ref-link&quot;&gt;JupyterLab&lt;/a&gt;, feel free to use that instead. To launch a Jupyter notebook, run the following:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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 gp-VirtualEnv&quot;&gt;(altair-venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;notebook
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(altair-venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;jupyter&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;notebook
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;The second command launches the &lt;a href=&quot;/ref/code-editors-ides/jupyter-notebook/&quot; class=&quot;ref-link&quot;&gt;Jupyter Notebook&lt;/a&gt; server in your browser. Create a new notebook and enter the following code, which builds a bar chart from a small &lt;a href=&quot;/ref/glossary/dataframe/&quot; class=&quot;ref-link&quot;&gt;DataFrame&lt;/a&gt; containing daily step counts for one week:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;python&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--blue&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&gt;Python&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;codeblock__contents&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;kn&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;altair&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;alt&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;pandas&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;pd&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;steps&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;Day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1-Mon&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2-Tue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;3-Wed&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;4-Thu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;5-Fri&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;6-Sat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;7-Sun&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;Steps&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;6200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9800&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9870&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3769&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;n&quot;&gt;weekly_steps&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Chart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mark_bar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Day&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Steps&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;n&quot;&gt;weekly_steps&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;You should see a bar chart displaying daily step counts:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/altair-weekly-steps-bar-chart.a3b50fc2fd70.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/altair-weekly-steps-bar-chart.a3b50fc2fd70.png&quot; width=&quot;2048&quot; height=&quot;1152&quot; srcset=&quot;/cdn-cgi/image/width=512,format=auto/https://files.realpython.com/media/altair-weekly-steps-bar-chart.a3b50fc2fd70.png 512w, /cdn-cgi/image/width=682,format=auto/https://files.realpython.com/media/altair-weekly-steps-bar-chart.a3b50fc2fd70.png 682w, /cdn-cgi/image/width=1024,format=auto/https://files.realpython.com/media/altair-weekly-steps-bar-chart.a3b50fc2fd70.png 1024w, /cdn-cgi/image/width=2048,format=auto/https://files.realpython.com/media/altair-weekly-steps-bar-chart.a3b50fc2fd70.png 2048w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Altair Bar Chart Showing Daily Step Counts&quot; data-asset=&quot;6880&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Step Counts as a Bar Chart&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;The dataset is intentionally minimal because data isn’t the main focus: it has seven rows for seven days, and two columns for the day name and step count. Notice how the &lt;code&gt;weekly_steps&lt;/code&gt; chart is constructed. Every Altair chart follows this same pattern. It’s built from these three building blocks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data&lt;/strong&gt;: A &lt;a href=&quot;https://realpython.com/pandas-dataframe/&quot;&gt;pandas DataFrame&lt;/a&gt; handed to &lt;code&gt;alt.Chart()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mark&lt;/strong&gt;: The visual shape you want, chosen via &lt;code&gt;.mark_*()&lt;/code&gt;. Here, &lt;code&gt;.mark_bar()&lt;/code&gt; draws bars. Other options include &lt;code&gt;.mark_point()&lt;/code&gt;, &lt;code&gt;.mark_line()&lt;/code&gt;, and &lt;code&gt;.mark_arc()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Encode&lt;/strong&gt;: The mapping from data columns to visual properties, declared inside &lt;code&gt;.encode()&lt;/code&gt;. Here, &lt;code&gt;Day&lt;/code&gt; goes to the x-axis and &lt;code&gt;Steps&lt;/code&gt; to the y-axis.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is Altair’s core grammar in action: &lt;strong&gt;Data → Mark → Encode&lt;/strong&gt;. You’ll use it every time.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/altair-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/altair-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Leverage OpenAI&#x27;s API in Your Python Projects</title>
      <id>https://realpython.com/courses/leverage-openais-api-in-your-python-projects/</id>
      <link href="https://realpython.com/courses/leverage-openais-api-in-your-python-projects/"/>
      <updated>2026-04-21T14:00:00+00:00</updated>
      <summary>Learn how to use the ChatGPT API with Python&#x27;s openai library to send prompts, control AI behavior with roles, and get structured outputs.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;code&gt;openai&lt;/code&gt; library provides the tools you need to integrate the ChatGPT API into your Python applications. With it, you can send text prompts to the API and receive AI-generated responses. You can also guide the AI&amp;rsquo;s behavior with &lt;code&gt;developer&lt;/code&gt; role messages and handle both simple text generation and more complex code creation tasks.&lt;/p&gt;
&lt;p&gt;After watching this video course, you&amp;rsquo;ll understand how examples like this work under the hood. You&amp;rsquo;ll learn the fundamentals of using the ChatGPT API from Python and have code examples you can adapt for your own 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>Gemini CLI vs Claude Code: Which to Choose for Python Tasks</title>
      <id>https://realpython.com/gemini-cli-vs-claude-code/</id>
      <link href="https://realpython.com/gemini-cli-vs-claude-code/"/>
      <updated>2026-04-20T14:00:00+00:00</updated>
      <summary>Gemini CLI vs Claude Code: compare setup, performance, code quality, and cost to find the right Python AI coding tool for your workflow.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When comparing Gemini CLI vs Claude Code, the answer to “which one is better?” is usually &lt;em&gt;it depends&lt;/em&gt;. Both tools boost productivity for Python developers, but they have different strengths. Choosing the right one depends on your budget, workflow, and what you value most in generated code.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/ref/ai-coding-tools/gemini-cli/&quot; class=&quot;ref-link&quot;&gt;Gemini CLI&lt;/a&gt;, for instance, is known for its generous free tier, while &lt;a href=&quot;/ref/ai-coding-tools/claude-code/&quot; class=&quot;ref-link&quot;&gt;Claude Code&lt;/a&gt; is a paid tool known for its production-ready output.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll explore features such as &lt;strong&gt;user experience&lt;/strong&gt;, &lt;strong&gt;performance&lt;/strong&gt;, &lt;strong&gt;code quality&lt;/strong&gt;, and &lt;strong&gt;usage cost&lt;/strong&gt; to help make that decision easier. The AI coding assistance these tools provide right in your terminal generally makes writing Python code much more seamless, helping you save time and be more productive.&lt;/p&gt;
&lt;p&gt;This table highlights the key differences at a glance:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/th&gt;
&lt;th class=&quot;text-center&quot;&gt;&lt;strong&gt;Gemini CLI&lt;/strong&gt;&lt;/th&gt;
&lt;th class=&quot;text-center&quot;&gt;&lt;strong&gt;Claude Code&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;You need free generous usage limits&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;✅&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need Google Cloud integration&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;✅&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need faster task completion&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;—&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need code close to production quality&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;—&lt;/td&gt;
&lt;td class=&quot;text-center&quot;&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;You can see that Gemini CLI is a promising choice if you’re looking for free usage limits and prefer Google Cloud integration. However, if you want to complete tasks faster, Claude Code has an edge. Both tools produce code of good quality, but Claude Code generates code that is closer to production quality. If you’d like a more thorough comparison, then read on.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/gemini-cli-vs-claude-code-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-gemini-cli-vs-claude-code-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; for the to-do app projects built with Gemini CLI and Claude Code in this tutorial.&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.a032542568e1.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 “Gemini CLI vs Claude Code: Which to Choose for Python Tasks” 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/gemini-cli-vs-claude-code/&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;A scientist comparing two coding terminals labeled Gemini and Claude on a balance scale with gauges for cost, speed, and quality, a Python-branded processor, and ink bottles.&quot; src=&quot;https://files.realpython.com/media/Gemini-CLI-vs-Claude-Code-Which-to-Choose-for-Python-Programming_Watermarked.d928bd4957f9.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Gemini-CLI-vs-Claude-Code-Which-to-Choose-for-Python-Programming_Watermarked.d928bd4957f9.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Gemini-CLI-vs-Claude-Code-Which-to-Choose-for-Python-Programming_Watermarked.d928bd4957f9.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Gemini-CLI-vs-Claude-Code-Which-to-Choose-for-Python-Programming_Watermarked.d928bd4957f9.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Gemini-CLI-vs-Claude-Code-Which-to-Choose-for-Python-Programming_Watermarked.d928bd4957f9.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.a032542568e1.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/gemini-cli-vs-claude-code/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Gemini CLI vs Claude Code: Which to Choose for Python Tasks&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Compare Gemini CLI and Claude Code across user experience, performance, code quality, and cost to find the right AI coding tool for you.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;metrics-comparison-gemini-cli-vs-claude-code&quot;&gt;Metrics Comparison: Gemini CLI vs Claude Code&lt;a class=&quot;headerlink&quot; href=&quot;#metrics-comparison-gemini-cli-vs-claude-code&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To ground the comparisons in hands-on data, both tools are tested using the same prompt throughout this tutorial:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prompt&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Build a CLI-based mini to-do application in Python. It should allow users to create tasks, mark tasks as completed, list tasks with filtering for completed and pending tasks, delete tasks, include error handling, persist tasks to a local &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;JSON&lt;/a&gt; file, and include basic unit tests.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For a fair comparison, Gemini CLI is tested on its free tier using Gemini 3 Flash Preview, which is the default model the free tier provides access to. Claude Code is tested on the Pro plan using Claude Sonnet 4.6, which is the model Claude Code primarily uses for everyday interactions on that plan.&lt;/p&gt;
&lt;p&gt;Each tool will run this prompt three times. Completion time, &lt;a href=&quot;/ref/ai-coding-glossary/token/&quot; class=&quot;ref-link&quot;&gt;token&lt;/a&gt; usage, and the quality of the generated code are recorded from the runs and are referenced in the Performance, Code Quality, and Usage Cost sections of this tutorial.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;
If you want to learn more about these tools so you can compare them yourself, Real Python has you covered. The &lt;a href=&quot;https://realpython.com/how-to-use-gemini-cli/&quot;&gt;How to Use Google’s Gemini CLI for AI Code Assistance&lt;/a&gt; tutorial covers installation, authentication, and hands-on usage, while the &lt;a href=&quot;https://realpython.com/courses/getting-started-claude-code/&quot;&gt;Getting Started With Claude Code&lt;/a&gt; video course walks you through setup and core features.&lt;/p&gt;
&lt;p&gt;You should also be comfortable using your &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt;, since both Gemini CLI and Claude Code are command-line tools.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The table below provides more detailed metrics to help with each comparison:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Gemini CLI&lt;/th&gt;
&lt;th&gt;Claude Code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User Experience&lt;/td&gt;
&lt;td&gt;Intuitive, browser-based auth, terminal-native&lt;/td&gt;
&lt;td&gt;Minimal setup, terminal-native, strong project awareness&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Good performance, however slower generation speed&lt;/td&gt;
&lt;td&gt;Good performance, code is generated generally faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code Quality&lt;/td&gt;
&lt;td&gt;Solid, better for exploratory tasks&lt;/td&gt;
&lt;td&gt;Strong, better for production-grade work&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Usage Cost&lt;/td&gt;
&lt;td&gt;Free tier available; paid plans for heavier use&lt;/td&gt;
&lt;td&gt;Requires a paid subscription to get started&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;The following sections explore each metric in detail, so you can decide which tool fits your workflow best.&lt;/p&gt;
&lt;h2 id=&quot;user-experience&quot;&gt;User Experience&lt;a class=&quot;headerlink&quot; href=&quot;#user-experience&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When writing Python programs, it helps to be able to comfortably use your tools without dealing with unintuitive interfaces. Both Gemini CLI and Claude Code prioritize a smooth terminal experience, but user experience goes beyond the interface itself—installation, setup, available models, and features offered are also part of it.&lt;/p&gt;
&lt;h3 id=&quot;installation-and-setup&quot;&gt;Installation and Setup&lt;a class=&quot;headerlink&quot; href=&quot;#installation-and-setup&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A few differences exist between Gemini CLI and Claude Code during installation. Gemini CLI requires a Google account for authentication. Claude Code doesn’t need a Google account. Instead, it requires an Anthropic subscription or &lt;a href=&quot;/ref/glossary/api/&quot; class=&quot;ref-link&quot;&gt;API&lt;/a&gt; key.&lt;/p&gt;
&lt;p&gt;Gemini CLI is first installed using npm:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;mr-2 noselect&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;Language: &lt;/span&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; aria-label=&quot;Toggle prompts and output&quot; role=&quot;button&quot; tabindex=&quot;0&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.a032542568e1.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 class=&quot;codeblock__contents&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;npm&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-g&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;@google/gemini-cli
&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; aria-label=&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.a032542568e1.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;p&gt;You can also install Gemini CLI with Anaconda, MacPorts, or Homebrew, which you can find in the &lt;a href=&quot;https://geminicli.com/docs/&quot;&gt;Gemini CLI documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When installing Claude Code, you run the following commands:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/gemini-cli-vs-claude-code/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/gemini-cli-vs-claude-code/ »&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 #291: Reassessing the LLM Landscape &amp; Summoning Ghosts</title>
      <id>https://realpython.com/podcasts/rpp/291/</id>
      <link href="https://realpython.com/podcasts/rpp/291/"/>
      <updated>2026-04-17T12:00:00+00:00</updated>
      <summary>What are the current techniques being employed to improve the performance of LLM-based systems? How is the industry shifting from post-training towards context engineering and multi-agent orchestration? This week on the show, Jodie Burchell, data scientist and Python Advocacy Team Lead at JetBrains, returns to discuss the current AI coding landscape.</summary>
      <content type="html">
        &lt;p&gt;What are the current techniques being employed to improve the performance of LLM-based systems? How is the industry shifting from post-training towards context engineering and multi-agent orchestration? This week on the show, Jodie Burchell, data scientist and Python Advocacy Team Lead at JetBrains, returns to discuss the current AI coding landscape.&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>Learning Path: Python Game Development</title>
      <id>https://realpython.com/learning-paths/python-game-development/</id>
      <link href="https://realpython.com/learning-paths/python-game-development/"/>
      <updated>2026-04-16T12:00:00+00:00</updated>
      <summary>Build Python games from command-line projects to 2D graphical games with turtle, Tkinter, Pygame, and Arcade.</summary>
      <content type="html">
        &lt;p&gt;Build Python games from command-line projects to 2D graphical games with turtle, Tkinter, Pygame, and Arcade.&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>Vector Databases and Embeddings With ChromaDB</title>
      <id>https://realpython.com/courses/vector-databases-embeddings-chromadb/</id>
      <link href="https://realpython.com/courses/vector-databases-embeddings-chromadb/"/>
      <updated>2026-04-14T14:00:00+00:00</updated>
      <summary>Learn how to use ChromaDB, an open-source vector database, to store embeddings and give context to large language models in Python.</summary>
      <content type="html">
        &lt;p&gt;The era of &lt;a href=&quot;https://en.wikipedia.org/wiki/Large_language_model&quot;&gt;large language models&lt;/a&gt; (LLMs) is here, bringing with it rapidly evolving libraries like &lt;a href=&quot;https://docs.trychroma.com/&quot;&gt;ChromaDB&lt;/a&gt; that help augment LLM applications. You&amp;rsquo;ve most likely heard of chatbots like OpenAI&amp;rsquo;s &lt;a href=&quot;https://realpython.com/chatgpt-coding-mentor-python/&quot;&gt;ChatGPT&lt;/a&gt;, and perhaps you&amp;rsquo;ve even experienced their remarkable ability to reason about &lt;a href=&quot;https://en.wikipedia.org/wiki/Natural_language_processing&quot;&gt;natural language processing (NLP)&lt;/a&gt; problems.&lt;/p&gt;
&lt;p&gt;Modern LLMs, while imperfect, can accurately solve a wide range of problems and provide correct answers to many questions. However, due to the limits of their training and the number of text tokens they can process, LLMs aren&amp;rsquo;t a silver bullet for all tasks.&lt;/p&gt;
&lt;p&gt;You wouldn&amp;rsquo;t expect an LLM to deliver relevant responses about topics that don&amp;rsquo;t appear in its training data. For example, if you asked ChatGPT to summarize information in confidential company documents, you&amp;rsquo;d be out of luck. You could show some of these documents to ChatGPT, but there&amp;rsquo;s a limit to how many documents you can upload before you exceed ChatGPT&amp;rsquo;s maximum token count. How would you select which documents to show ChatGPT?&lt;/p&gt;
&lt;p&gt;To address these limitations and scale your LLM applications, a great option is to use a vector database like ChromaDB. A &lt;strong&gt;vector database&lt;/strong&gt; allows you to store encoded unstructured objects, like text, as lists of numbers that can be compared to one another. For instance, you can find a collection of documents relevant to a question you&amp;rsquo;d like an LLM to answer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Representing &lt;strong&gt;unstructured objects&lt;/strong&gt; with &lt;strong&gt;vectors&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;word&lt;/strong&gt; and &lt;strong&gt;text embeddings&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Harnessing the power of &lt;strong&gt;vector databases&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Encoding&lt;/strong&gt; and &lt;strong&gt;querying&lt;/strong&gt; over documents with ChromaDB&lt;/li&gt;
&lt;li&gt;Providing &lt;strong&gt;context&lt;/strong&gt; to &lt;strong&gt;LLMs&lt;/strong&gt; like ChatGPT with ChromaDB&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After watching, you&amp;rsquo;ll have the foundational knowledge to use ChromaDB in your NLP or LLM applications. Before watching, you should be comfortable with the &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;basics of Python&lt;/a&gt; and high school math.&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 #290: Advice on Managing Projects &amp; Making Python Classes Friendly</title>
      <id>https://realpython.com/podcasts/rpp/290/</id>
      <link href="https://realpython.com/podcasts/rpp/290/"/>
      <updated>2026-04-10T12:00:00+00:00</updated>
      <summary>What goes into managing a major project? What techniques can you employ for a project that&#x27;s in crisis? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;What goes into managing a major project? What techniques can you employ for a project that&#x27;s in crisis? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Using Loguru to Simplify Python Logging</title>
      <id>https://realpython.com/courses/using-loguru-to-simplify-python-logging/</id>
      <link href="https://realpython.com/courses/using-loguru-to-simplify-python-logging/"/>
      <updated>2026-04-07T14:00:00+00:00</updated>
      <summary>Learn how to use Loguru for simpler Python logging, from zero-config setup and custom formats to file rotation, retention, and adding context.</summary>
      <content type="html">
        &lt;p&gt;Logging is a vital programming practice that helps you track, understand, and debug your application&amp;rsquo;s behavior. Loguru is a Python library that provides simpler, more intuitive logging compared to Python&amp;rsquo;s built-in &lt;code&gt;logging&lt;/code&gt; module.&lt;/p&gt;
&lt;p&gt;Good logging gives you insights into your program&amp;rsquo;s execution, helps you diagnose issues, and provides valuable information about your application&amp;rsquo;s health in production. Without proper logging, you risk missing critical errors, spending countless hours &lt;a href=&quot;https://realpython.com/python-debugging-pdb/&quot;&gt;debugging&lt;/a&gt; blind spots, and potentially undermining your project&amp;rsquo;s overall stability.&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;&lt;strong&gt;Logging&lt;/strong&gt; in Python can be &lt;strong&gt;simple and intuitive&lt;/strong&gt; with the right tools.&lt;/li&gt;
&lt;li&gt;Using Loguru lets you &lt;strong&gt;start logging immediately&lt;/strong&gt; without complex configuration.&lt;/li&gt;
&lt;li&gt;You can &lt;strong&gt;customize log formats&lt;/strong&gt; and send logs to multiple destinations like files, the standard error stream, or external services.&lt;/li&gt;
&lt;li&gt;Loguru provides &lt;strong&gt;powerful debugging capabilities&lt;/strong&gt; that make troubleshooting easier.&lt;/li&gt;
&lt;li&gt;Loguru supports &lt;strong&gt;structured logging&lt;/strong&gt; with JSON formatting for modern applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After watching this course, you&amp;rsquo;ll be able to quickly implement better logging in your Python applications. You&amp;rsquo;ll spend less time wrestling with logging configuration and more time using logs effectively to debug issues. This will help you build production-ready applications that are easier to troubleshoot when problems occur.&lt;/p&gt;
&lt;p&gt;To get the most from this course, you should be familiar with Python concepts like &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/primer-on-python-decorators/&quot;&gt;decorators&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-with-statement/&quot;&gt;context managers&lt;/a&gt;. You might also find it helpful to have some experience with Python&amp;rsquo;s built-in &lt;a href=&quot;https://realpython.com/python-logging/&quot;&gt;&lt;code&gt;logging&lt;/code&gt;&lt;/a&gt; module, though this isn&amp;rsquo;t required.&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t worry if you&amp;rsquo;re new to logging in Python. This course will guide you through everything you need to know to get started with Loguru and implement effective logging in your 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>Adding Python to PATH</title>
      <id>https://realpython.com/courses/adding-python-to-path/</id>
      <link href="https://realpython.com/courses/adding-python-to-path/"/>
      <updated>2026-03-31T14:00:00+00:00</updated>
      <summary>Learn how to add Python to your PATH environment variable on Windows, macOS, and Linux so you can run Python from the command line.</summary>
      <content type="html">
        &lt;p&gt;You may need to add Python to &lt;code&gt;PATH&lt;/code&gt; if you&amp;rsquo;ve &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;installed Python&lt;/a&gt;, but typing &lt;code&gt;python&lt;/code&gt; on the command line doesn&amp;rsquo;t seem to work. You might see a message saying that &lt;code&gt;python&lt;/code&gt; isn&amp;rsquo;t recognized, or you might end up running the wrong version of Python.&lt;/p&gt;
&lt;p&gt;A common fix for these problems is adding Python to the &lt;code&gt;PATH&lt;/code&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Environment_variable&quot;&gt;environment variable&lt;/a&gt;. In this video course, you&amp;rsquo;ll learn how to add Python to &lt;code&gt;PATH&lt;/code&gt;. You&amp;rsquo;ll also learn what &lt;code&gt;PATH&lt;/code&gt; is and why it&amp;rsquo;s essential for tools like the command line to be able to find your Python installation.&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 #289: Limitations in Human and Automated Code Review</title>
      <id>https://realpython.com/podcasts/rpp/289/</id>
      <link href="https://realpython.com/podcasts/rpp/289/"/>
      <updated>2026-03-27T12:00:00+00:00</updated>
      <summary>With the mountains of Python code that it&#x27;s possible to generate now, how&#x27;s your code review going? What are the limitations of human review, and where does machine review excel? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;With the mountains of Python code that it&#x27;s possible to generate now, how&#x27;s your code review going? What are the limitations of human review, and where does machine review excel? Christopher Trudeau is back on the show this week with 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>Understanding CRUD Operations in SQL</title>
      <id>https://realpython.com/courses/understanding-crud-operations-sql/</id>
      <link href="https://realpython.com/courses/understanding-crud-operations-sql/"/>
      <updated>2026-03-24T14:00:00+00:00</updated>
      <summary>Learn how CRUD operations work in SQL by writing raw SQL queries with SQLite and using SQLAlchemy as an ORM in Python.</summary>
      <content type="html">
        &lt;p&gt;CRUD operations are at the heart of nearly every application you interact with. As a developer, you usually want to create data, read or retrieve data, update data, and delete data. Whether you access a database or interact with a REST API, only when all four operations are present are you able to make a complete data roundtrip in your app.&lt;/p&gt;
&lt;p&gt;Creating, reading, updating, and deleting are so vital in software development that these methods are widely referred to as &lt;strong&gt;CRUD&lt;/strong&gt;. Understanding CRUD will give you an actionable blueprint when you build applications and help you understand how the applications you use work behind the scenes. So, what exactly does CRUD mean?&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 #288: Automate Exploratory Data Analysis &amp; Invent Python Comprehensions</title>
      <id>https://realpython.com/podcasts/rpp/288/</id>
      <link href="https://realpython.com/podcasts/rpp/288/"/>
      <updated>2026-03-20T12:00:00+00:00</updated>
      <summary>How do you quickly get an understanding of what&#x27;s inside a new set of data? How can you share an exploratory data analysis with your team? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How do you quickly get an understanding of what&#x27;s inside a new set of data? How can you share an exploratory data analysis with your team? Christopher Trudeau is back on the show this week with 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>Learning Path: LLM Application Development With Python</title>
      <id>https://realpython.com/learning-paths/llm-application-development-python/</id>
      <link href="https://realpython.com/learning-paths/llm-application-development-python/"/>
      <updated>2026-03-19T12:00:00+00:00</updated>
      <summary>Build LLM-powered applications in Python. Call model APIs, craft prompts, add retrieval-augmented generation, create AI agents, and connect via MCP.</summary>
      <content type="html">
        &lt;p&gt;Build LLM-powered applications in Python. Call model APIs, craft prompts, add retrieval-augmented generation, create AI agents, and connect via MCP.&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>Downloading Files From URLs With Python</title>
      <id>https://realpython.com/courses/downloading-files-urls/</id>
      <link href="https://realpython.com/courses/downloading-files-urls/"/>
      <updated>2026-03-17T14:00:00+00:00</updated>
      <summary>Learn to download files from URLs with Python using urllib and requests, including data streaming for large files.</summary>
      <content type="html">
        &lt;p&gt;Python makes it straightforward to download files from a URL with its robust set of libraries. For quick tasks, you can use the built-in &lt;code&gt;urllib&lt;/code&gt; module or the &lt;code&gt;requests&lt;/code&gt; library to fetch and save files. When working with large files, streaming data in chunks can help save memory and improve performance.&lt;/p&gt;
&lt;p&gt;You can also perform parallel file downloads using &lt;code&gt;ThreadPoolExecutor&lt;/code&gt; for multithreading or the &lt;code&gt;aiohttp&lt;/code&gt; library for asynchronous tasks. These approaches allow you to handle multiple downloads concurrently, significantly reducing the total download time if you&amp;rsquo;re handling many files.&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;You can use Python to &lt;strong&gt;download files with libraries&lt;/strong&gt; like &lt;strong&gt;&lt;code&gt;urllib&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;requests&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To &lt;strong&gt;download a file using a URL&lt;/strong&gt; in Python, you can use &lt;strong&gt;&lt;code&gt;urlretrieve()&lt;/code&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;code&gt;requests.get()&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To &lt;strong&gt;extract data from a URL&lt;/strong&gt; in Python, you use the response object from &lt;strong&gt;&lt;code&gt;requests&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To &lt;strong&gt;download a CSV file from a URL&lt;/strong&gt; in Python, you may need to specify the format in the URL or query parameters.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll be downloading a range of economic data from the World Bank Open Data platform.&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 #287: Crafting and Editing In-Depth Tutorials at Real Python</title>
      <id>https://realpython.com/podcasts/rpp/287/</id>
      <link href="https://realpython.com/podcasts/rpp/287/"/>
      <updated>2026-03-13T12:00:00+00:00</updated>
      <summary>What goes into creating the tutorials you read at Real Python? What are the steps in the editorial process, and who are the people behind the scenes? This week on the show, Real Python team members Martin Breuss, Brenda Weleschuk, and Philipp Acsany join us to discuss topic curation, review stages, and quality assurance.</summary>
      <content type="html">
        &lt;p&gt;What goes into creating the tutorials you read at Real Python? What are the steps in the editorial process, and who are the people behind the scenes? This week on the show, Real Python team members Martin Breuss, Brenda Weleschuk, and Philipp Acsany join us to discuss topic curation, review stages, and quality assurance.&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>Learning Path: Python Coding With AI</title>
      <id>https://realpython.com/learning-paths/coding-with-ai/</id>
      <link href="https://realpython.com/learning-paths/coding-with-ai/"/>
      <updated>2025-12-07T12:00:00+00:00</updated>
      <summary>Use AI coding assistants to write, review, and debug Python code faster. Pick from Claude Code, Cursor, or Gemini CLI and start coding.</summary>
      <content type="html">
        &lt;p&gt;Use AI coding assistants to write, review, and debug Python code faster. Pick from Claude Code, Cursor, or Gemini CLI and start coding.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Learning Path: Python Control Flow and Loops</title>
      <id>https://realpython.com/learning-paths/python-control-flow-and-loops/</id>
      <link href="https://realpython.com/learning-paths/python-control-flow-and-loops/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn Python control flow and loops. Use conditional statements, Boolean operators, for and while loops, and keywords like break and continue.</summary>
      <content type="html">
        &lt;p&gt;Learn Python control flow and loops. Use conditional statements, Boolean operators, for and while loops, and keywords like break and continue.&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>Learning Path: Modules and Packages</title>
      <id>https://realpython.com/learning-paths/modules-and-packages/</id>
      <link href="https://realpython.com/learning-paths/modules-and-packages/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn Python&#x27;s import system, organize code into modules and packages, manage dependencies with pip, and publish to PyPI.</summary>
      <content type="html">
        &lt;p&gt;Learn Python&#x27;s import system, organize code into modules and packages, manage dependencies with pip, and publish to PyPI.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Learning Path: Functions and Scopes</title>
      <id>https://realpython.com/learning-paths/functions-and-scopes/</id>
      <link href="https://realpython.com/learning-paths/functions-and-scopes/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn to define Python functions, use parameters and return values, create inner functions, and understand namespaces and scope.</summary>
      <content type="html">
        &lt;p&gt;Learn to define Python functions, use parameters and return values, create inner functions, and understand namespaces and scope.&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>Learning Path: Create Graphical User Interfaces (GUI)</title>
      <id>https://realpython.com/learning-paths/python-gui-programming/</id>
      <link href="https://realpython.com/learning-paths/python-gui-programming/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Build Python GUI applications with Tkinter, PyQt, wxPython, and Kivy. Learn layouts, event handling, threading, and database integration.</summary>
      <content type="html">
        &lt;p&gt;Build Python GUI applications with Tkinter, PyQt, wxPython, and Kivy. Learn layouts, event handling, threading, and database integration.&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>Learning Path: Important Standard Library Modules</title>
      <id>https://realpython.com/learning-paths/standard-library-modules-you-should-know/</id>
      <link href="https://realpython.com/learning-paths/standard-library-modules-you-should-know/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Explore Python standard library modules including math, datetime, JSON, CSV, regex, subprocess, and argparse through hands-on tutorials and courses.</summary>
      <content type="html">
        &lt;p&gt;Explore Python standard library modules including math, datetime, JSON, CSV, regex, subprocess, and argparse through hands-on tutorials and courses.&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>Learning Path: Network Programming and Security</title>
      <id>https://realpython.com/learning-paths/network-programming-and-security/</id>
      <link href="https://realpython.com/learning-paths/network-programming-and-security/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn network programming and security in Python. Work with CRUD operations, REST APIs, HTTPS, and socket programming to build networked apps.</summary>
      <content type="html">
        &lt;p&gt;Learn network programming and security in Python. Work with CRUD operations, REST APIs, HTTPS, and socket programming to build networked apps.&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>Learning Path: Functional Programming With Python</title>
      <id>https://realpython.com/learning-paths/functional-programming/</id>
      <link href="https://realpython.com/learning-paths/functional-programming/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Explore functional programming in Python. Learn lambda functions, map(), filter(), reduce(), closures, decorators, and recursion.</summary>
      <content type="html">
        &lt;p&gt;Explore functional programming in Python. Learn lambda functions, map(), filter(), reduce(), closures, decorators, and recursion.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  

</feed>
