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

  
    <entry>
      <title>How to Automate Your Workflow With Claude Code Hooks</title>
      <id>https://realpython.com/claude-code-hooks/</id>
      <link href="https://realpython.com/claude-code-hooks/"/>
      <updated>2026-10-19T14:00:00+00:00</updated>
      <summary>Learn how to use Claude Code hooks that auto-format your Python code after every edit, enforce your chosen tools, and ping you when a task finishes.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you pair with Claude Code, some steps shouldn’t be left to chance, and Claude Code hooks are how you lock them in. You want a heads-up when it finishes a long task, a guarantee that it sticks to your project’s approved tools, and a promise that every edit is formatted to your code standards, without repeating yourself each time. Asking the model to remember all of that works until it doesn’t.&lt;/p&gt;
&lt;p&gt;Hooks make these actions deterministic: they fire on the event you choose, every time. A hook is nothing more than a command you register to run when a specific event happens. It doesn’t wait for the model to choose to act, which is what makes it reliable.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll set up these hooks in a project of your own. Here’s the auto-formatter at work, cleaning up a file the moment Claude edits it:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/hook-demo.96672a5550b3.gif&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/hook-demo.96672a5550b3.gif&quot; width=&quot;886&quot; height=&quot;605&quot; srcset=&quot;/cdn-cgi/image/width=221,format=auto/https://files.realpython.com/media/hook-demo.96672a5550b3.gif 221w, /cdn-cgi/image/width=295,format=auto/https://files.realpython.com/media/hook-demo.96672a5550b3.gif 295w, /cdn-cgi/image/width=443,format=auto/https://files.realpython.com/media/hook-demo.96672a5550b3.gif 443w, /cdn-cgi/image/width=886,format=auto/https://files.realpython.com/media/hook-demo.96672a5550b3.gif 886w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Claude Code Hooks: a PostToolUse Hook Reformatting a Python File With ruff on Save&quot; data-asset=&quot;7227&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;A PostToolUse Hook Formatting Claude&#x27;s Edit With Ruff&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;As you build them, you’ll learn the three parts a hook is made of and the exit-code contract that lets a hook block or redirect what the model is about to do.&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-code-hooks-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-claude-code-hooks-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; you’ll use to build the desktop notifier, pip guard, and auto-formatter hooks you wire up 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.8f1dcd28e216.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 Automate Your Workflow With Claude Code Hooks” 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-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/claude-code-hooks/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #fe7e73;&quot; alt=&quot;A woman leans against a factory conveyor belt carrying code files and folders, while three overhead hooks lower onto the line beside a machine panel showing the Python logo.&quot; src=&quot;https://files.realpython.com/media/Claude-Code-Hooks-for-Workflow-Automation_Watermarked.1f77f20e84a3.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Claude-Code-Hooks-for-Workflow-Automation_Watermarked.1f77f20e84a3.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Claude-Code-Hooks-for-Workflow-Automation_Watermarked.1f77f20e84a3.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Claude-Code-Hooks-for-Workflow-Automation_Watermarked.1f77f20e84a3.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Claude-Code-Hooks-for-Workflow-Automation_Watermarked.1f77f20e84a3.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.8f1dcd28e216.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 position-relative&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-code-hooks/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Automate Your Workflow With Claude Code Hooks&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of Claude Code hooks, including the Stop, PreToolUse, and PostToolUse events and the exit codes that block an action.&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;To follow along, you should be comfortable with intermediate Python, the terminal, and reading a bit of &lt;a href=&quot;/ref/glossary/json/&quot; class=&quot;ref-link&quot;&gt;JSON&lt;/a&gt;. You should also have spent some time in Claude Code already.&lt;/p&gt;
&lt;p&gt;If it’s new to you, then Real Python’s &lt;a href=&quot;https://realpython.com/how-to-use-claude-code/&quot;&gt;How to Use Claude Code to Write and Debug Python&lt;/a&gt; tutorial walks through the basics, and 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 covers the same ground on screen.&lt;/p&gt;
&lt;p&gt;You’ll need a few tools on your system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/ref/ai-coding-tools/claude-code/&quot; class=&quot;ref-link&quot;&gt;Claude Code&lt;/a&gt; 2.1.187 or later&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python 3.12 or later&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/ref/tools/uv/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;uv&lt;/code&gt;&lt;/a&gt; 0.11.6 or later&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/ref/tools/ruff/&quot; class=&quot;ref-link&quot;&gt;Ruff&lt;/a&gt; 0.15.20 or later&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you don’t have &lt;code&gt;uv&lt;/code&gt; yet, then Real Python’s guide on &lt;a href=&quot;https://realpython.com/python-uv/#installing-uv-to-manage-python-projects&quot;&gt;installing &lt;code&gt;uv&lt;/code&gt;&lt;/a&gt; walks you through it. You’ll install Ruff later, when you build the formatting hook.&lt;/p&gt;
&lt;h2 id=&quot;step-1-ping-yourself-after-every-claude-response&quot;&gt;Step 1: Ping Yourself After Every Claude Response&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-ping-yourself-after-every-claude-response&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Start with a small &lt;code&gt;uv&lt;/code&gt;-managed project, the kind you’d actually work in. Spin one up with &lt;code&gt;uv&lt;/code&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;uv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;init&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--no-package&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;hooks-demo
&lt;span class=&quot;go&quot;&gt;Initialized project `hooks-demo` at `/home/you/hooks-demo`&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;hooks-demo
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;uv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;sync
&lt;span class=&quot;go&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; 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.8f1dcd28e216.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 gives you a project to work in: a &lt;a href=&quot;https://realpython.com/python-pyproject-toml/&quot;&gt;&lt;code&gt;pyproject.toml&lt;/code&gt;&lt;/a&gt;, a starter &lt;code&gt;main.py&lt;/code&gt;, and a few dotfiles. The &lt;code&gt;uv sync&lt;/code&gt; step creates the project’s &lt;a href=&quot;/ref/glossary/virtual-environment/&quot; class=&quot;ref-link&quot;&gt;virtual environment&lt;/a&gt; up front, so the hooks can run cleanly from the start.&lt;/p&gt;
&lt;p&gt;Now for your first improvement. When you hand &lt;a href=&quot;/ref/ai-coding-tools/claude/&quot; class=&quot;ref-link&quot;&gt;Claude&lt;/a&gt; a long task and look away, you might miss the moment Claude wraps up and lose a few minutes before you circle back. A hook on the &lt;code&gt;Stop&lt;/code&gt; event closes that gap, since &lt;code&gt;Stop&lt;/code&gt; fires every time Claude finishes a response. That makes it the right place to send yourself a desktop notification.&lt;/p&gt;
&lt;p&gt;Notifications look different on each operating system, so rather than hard-code one command, you’ll point the hook at a small Python script that works everywhere. Create a &lt;code&gt;.claude/hooks/&lt;/code&gt; folder at the root of your project, then save this as &lt;code&gt;.claude/hooks/notify_desktop.py&lt;/code&gt;:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Python&lt;/span&gt;
    &lt;span class=&quot;me-2&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Filename: &lt;/span&gt;&lt;code style=&quot;color: inherit; background: inherit;&quot;&gt;.claude/hooks/notify_desktop.py&lt;/code&gt;&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;json&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;platform&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;subprocess&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;sys&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;notify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;platform&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Darwin&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#x27;display notification &quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot; with title &quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;&#x27;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;subprocess&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;osascript&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-e&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Linux&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;subprocess&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;notify-send&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;check&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;False&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;True&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;notified&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Claude Code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Claude just finished responding&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;FileNotFoundError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;notified&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;False&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;notified&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Claude just finished responding&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&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.8f1dcd28e216.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 script reads the event that Claude Code sends on standard input, then picks the right notifier: &lt;code&gt;osascript&lt;/code&gt; on macOS and &lt;code&gt;notify-send&lt;/code&gt; on Linux. On Windows and other systems, or if the notifier isn’t installed, the hook falls back to a plain-text message so it never interrupts your session. You could also wire up a native Windows toast with a PowerShell module like &lt;a href=&quot;https://github.com/Windos/BurntToast&quot;&gt;&lt;code&gt;BurntToast&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Project-level hooks live in &lt;code&gt;.claude/settings.json&lt;/code&gt;, and every hook is made of three parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Event&lt;/strong&gt;: The moment the hook runs, like &lt;code&gt;Stop&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Matcher&lt;/strong&gt;: An optional filter that limits the hook to certain tools&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Command&lt;/strong&gt;: The shell command to run&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/claude-code-hooks/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/claude-code-hooks/ »&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 Automate Your Workflow With Claude Code Hooks</title>
      <id>https://realpython.com/quizzes/claude-code-hooks/</id>
      <link href="https://realpython.com/quizzes/claude-code-hooks/"/>
      <updated>2026-10-19T12:00:00+00:00</updated>
      <summary>Test your understanding of Claude Code hooks, including the Stop, PreToolUse, and PostToolUse events and the exit codes that block an action.</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/claude-code-hooks/&quot;&gt;How to Automate Your Workflow With Claude Code Hooks&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit the parts that make up a hook, the events
that fire before and after a tool call, and the exit codes that let a hook block or
redirect what Claude is about to do.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Round Numbers in Python</title>
      <id>https://realpython.com/python-rounding/</id>
      <link href="https://realpython.com/python-rounding/"/>
      <updated>2026-10-18T14:00:00+00:00</updated>
      <summary>Learn how Python&#x27;s round() works, why it rounds 2.5 to 2, and how you can manage rounding errors with decimal, NumPy, and pandas.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Rounding numbers in Python is an essential task, especially when dealing with data precision. Python’s built-in &lt;code&gt;round()&lt;/code&gt; &lt;a href=&quot;/ref/glossary/function/&quot; class=&quot;ref-link&quot;&gt;function&lt;/a&gt; uses the rounding half to even strategy, which rounds numbers like &lt;code&gt;2.5&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;3.5&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt;. This method helps minimize rounding bias in datasets. To round numbers to specific decimal places, you can use the &lt;code&gt;round()&lt;/code&gt; function with a second &lt;a href=&quot;/ref/glossary/argument/&quot; class=&quot;ref-link&quot;&gt;argument&lt;/a&gt; specifying the number of decimals.&lt;/p&gt;
&lt;p&gt;For more advanced rounding strategies, you can explore Python’s &lt;a href=&quot;https://realpython.com/python-fractions/#floating-point-and-decimal-numbers&quot;&gt;&lt;code&gt;decimal&lt;/code&gt;&lt;/a&gt; &lt;a href=&quot;/ref/glossary/module/&quot; class=&quot;ref-link&quot;&gt;module&lt;/a&gt; or use &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt; for data science applications. NumPy &lt;a href=&quot;/ref/glossary/array/&quot; class=&quot;ref-link&quot;&gt;arrays&lt;/a&gt; and pandas &lt;a href=&quot;/ref/glossary/dataframe/&quot; class=&quot;ref-link&quot;&gt;DataFrames&lt;/a&gt; offer methods for rounding numbers efficiently. In NumPy, you can use functions like &lt;code&gt;np.round()&lt;/code&gt;, &lt;code&gt;np.ceil()&lt;/code&gt;, &lt;code&gt;np.floor()&lt;/code&gt;, and &lt;code&gt;np.trunc()&lt;/code&gt; to apply different rounding strategies. For pandas, the &lt;code&gt;df.round()&lt;/code&gt; method allows rounding of entire DataFrames or specific columns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Python uses the &lt;strong&gt;rounding half to even&lt;/strong&gt; strategy, where ties round to the nearest even number.&lt;/li&gt;
&lt;li&gt;Python’s default rounding strategy minimizes &lt;strong&gt;rounding bias&lt;/strong&gt; in large datasets.&lt;/li&gt;
&lt;li&gt;You can round numbers to &lt;strong&gt;specific decimal places&lt;/strong&gt; using Python’s &lt;code&gt;round()&lt;/code&gt; function with a second argument.&lt;/li&gt;
&lt;li&gt;Different &lt;strong&gt;rounding strategies&lt;/strong&gt; can be applied using Python’s &lt;code&gt;decimal&lt;/code&gt; module or custom functions for precision control.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NumPy&lt;/strong&gt; and &lt;strong&gt;pandas&lt;/strong&gt; provide methods for rounding numbers in &lt;strong&gt;arrays&lt;/strong&gt; and &lt;strong&gt;DataFrames&lt;/strong&gt;, offering flexibility in data manipulation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You won’t get a treatise on numeric precision in computing, although you’ll touch briefly on the subject. Only a familiarity with the &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;fundamentals of Python&lt;/a&gt; is necessary, and the math should feel familiar if you’ve had high school algebra.&lt;/p&gt;
&lt;p&gt;You’ll start by looking at Python’s built-in rounding mechanism.&lt;/p&gt;
&lt;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.8f1dcd28e216.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 “Rounding Numbers 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-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-rounding/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #ff7e74;&quot; alt=&quot;How to Round Numbers in Python&quot; src=&quot;https://files.realpython.com/media/How-to-Round-Numbers-in-Python_Watermark.6fb8573ce8f5.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-Round-Numbers-in-Python_Watermark.6fb8573ce8f5.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Round-Numbers-in-Python_Watermark.6fb8573ce8f5.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Round-Numbers-in-Python_Watermark.6fb8573ce8f5.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Round-Numbers-in-Python_Watermark.6fb8573ce8f5.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.8f1dcd28e216.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 position-relative&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-rounding/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Rounding Numbers in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your knowledge of rounding numbers in Python.&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 Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-rounding-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-rounding-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; you’ll use to learn about rounding numbers in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;pythons-built-in-round-function&quot;&gt;Python’s Built-in &lt;code&gt;round()&lt;/code&gt; Function&lt;a class=&quot;headerlink&quot; href=&quot;#pythons-built-in-round-function&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python has a built-in &lt;code&gt;round()&lt;/code&gt; function that takes two numeric arguments, &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;ndigits&lt;/code&gt;, and returns the &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;number&lt;/a&gt; &lt;code&gt;n&lt;/code&gt; rounded to &lt;code&gt;ndigits&lt;/code&gt;. The &lt;code&gt;ndigits&lt;/code&gt; argument defaults to zero, so leaving it out results in a number rounded to an integer. As you’ll see, &lt;code&gt;round()&lt;/code&gt; may not work quite as you expect.&lt;/p&gt;
&lt;p&gt;The way most people are taught to round a number goes something like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Round the number &lt;code&gt;n&lt;/code&gt; to &lt;code&gt;p&lt;/code&gt; decimal places by first shifting the decimal point in &lt;code&gt;n&lt;/code&gt; by &lt;code&gt;p&lt;/code&gt; places. To do that, multiply &lt;code&gt;n&lt;/code&gt; by 10ᵖ (10 raised to the &lt;code&gt;p&lt;/code&gt; power) to get a new number, &lt;code&gt;m&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then look at the digit &lt;code&gt;d&lt;/code&gt; in the first decimal place of &lt;code&gt;m&lt;/code&gt;. If &lt;code&gt;d&lt;/code&gt; is less than 5, round &lt;code&gt;m&lt;/code&gt; down to the nearest integer. Otherwise, round &lt;code&gt;m&lt;/code&gt; up.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, shift the decimal point back &lt;code&gt;p&lt;/code&gt; places by dividing &lt;code&gt;m&lt;/code&gt; by 10ᵖ.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s an &lt;a href=&quot;/ref/computer-science-glossary/algorithm/&quot; class=&quot;ref-link&quot;&gt;algorithm&lt;/a&gt;! For example, the number &lt;code&gt;2.5&lt;/code&gt; rounded to the nearest whole number is &lt;code&gt;3&lt;/code&gt;. The number &lt;code&gt;1.64&lt;/code&gt; rounded to one decimal place is &lt;code&gt;1.6&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now open up an &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt; session and round &lt;code&gt;2.5&lt;/code&gt; to the nearest whole number using Python’s built-in &lt;a href=&quot;https://docs.python.org/3/builtins/functions.html#round&quot;&gt;&lt;code&gt;round()&lt;/code&gt;&lt;/a&gt; function:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;2.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;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.8f1dcd28e216.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;Gasp!&lt;/p&gt;
&lt;p&gt;Check out how &lt;code&gt;round()&lt;/code&gt; handles the number &lt;code&gt;1.5&lt;/code&gt;:&lt;/p&gt;
&lt;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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;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.8f1dcd28e216.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;So, &lt;code&gt;round()&lt;/code&gt; rounds &lt;code&gt;1.5&lt;/code&gt; up to &lt;code&gt;2&lt;/code&gt;, and &lt;code&gt;2.5&lt;/code&gt; down to &lt;code&gt;2&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;Before you go raising an issue on the Python bug tracker, rest assured you that &lt;code&gt;round(2.5)&lt;/code&gt; is &lt;em&gt;supposed&lt;/em&gt; to return &lt;code&gt;2&lt;/code&gt;. There’s a good reason why &lt;code&gt;round()&lt;/code&gt; behaves the way it does.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn that there are more ways to round a number than you might expect, each with unique advantages and disadvantages. &lt;code&gt;round()&lt;/code&gt; behaves according to a particular rounding strategy—which may or may not be the one you need for a given situation.&lt;/p&gt;
&lt;p&gt;You might be wondering, &lt;em&gt;Can the way I round numbers really have that much of an impact?&lt;/em&gt; Next up, take a look at just how extreme the effects of rounding can be.&lt;/p&gt;
&lt;h2 id=&quot;how-much-impact-can-rounding-have&quot;&gt;How Much Impact Can Rounding Have?&lt;a class=&quot;headerlink&quot; href=&quot;#how-much-impact-can-rounding-have&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Suppose you have an incredibly lucky day and find $100 on the ground. Rather than spending all your money at once, you decide to play it smart and invest your money by buying some shares of different stocks.&lt;/p&gt;
&lt;p&gt;The value of a stock depends on supply and demand. The more people there are who want to buy a stock, the more value that stock has, and vice versa. In high-volume stock markets, the value of a particular stock can fluctuate on a second-by-second basis.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-rounding/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-rounding/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Asynchronous Tasks With Django and Celery</title>
      <id>https://realpython.com/asynchronous-tasks-with-django-and-celery/</id>
      <link href="https://realpython.com/asynchronous-tasks-with-django-and-celery/"/>
      <updated>2026-10-18T14:00:00+00:00</updated>
      <summary>Integrate Django and Celery with Redis as a message broker, and move slow work like sending email out of the request cycle.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Celery is a distributed task queue that processes tasks asynchronously, so slow work doesn’t hold up your web app’s response. When you integrate Celery with your Django application, you can offload time-consuming tasks and keep your users from waiting. With Celery and Django, you can handle jobs like &lt;a href=&quot;https://realpython.com/python-send-email/&quot;&gt;sending emails&lt;/a&gt;, processing images, and analyzing data without slowing down your application.&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;Celery is a &lt;strong&gt;distributed task queue&lt;/strong&gt; that handles tasks outside the main Django app flow.&lt;/li&gt;
&lt;li&gt;Celery workers take care of &lt;strong&gt;offloading work&lt;/strong&gt;, while Celery beat handles &lt;strong&gt;scheduling tasks&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Using Celery in Django helps &lt;strong&gt;maintain app responsiveness&lt;/strong&gt; during time-intensive tasks.&lt;/li&gt;
&lt;li&gt;Configuring Celery in Django involves &lt;strong&gt;setting up a message broker&lt;/strong&gt; and &lt;strong&gt;defining tasks&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Running a task in Celery requires calling the task with &lt;code&gt;.delay()&lt;/code&gt; or &lt;code&gt;.apply_async()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Celery is not a message queue but &lt;strong&gt;uses a message broker like Redis&lt;/strong&gt; for communication.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’re in the right place if you’ve never used Celery in a Django app before, or if you’ve peeked into Celery’s documentation but couldn’t find your way around. You’ll learn how to configure Celery in Django to handle tasks asynchronously so that your application stays responsive.&lt;/p&gt;
&lt;p&gt;If you’re on Django 6.0 or later, then you’ll also see how Django’s built-in Tasks framework compares to Celery, so you can pick the right tool for your project.&lt;/p&gt;
&lt;p&gt;To focus this tutorial on the essentials, you’ll integrate Celery into an existing Django app. Go ahead and download the code for that app so that you can follow along:&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/django-celery-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-django-celery-code&quot; markdown&gt;Click here to download free the sample code&lt;/a&gt; you’ll use to integrate Celery into your Django app.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;python-celery-basics&quot;&gt;Python Celery Basics&lt;a class=&quot;headerlink&quot; href=&quot;#python-celery-basics&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.celeryq.dev/en/stable/index.html&quot;&gt;Celery&lt;/a&gt; is a distributed task &lt;a href=&quot;https://realpython.com/queue-in-python/&quot;&gt;queue&lt;/a&gt; that can collect, record, schedule, and perform tasks outside of your main program.&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; Celery &lt;a href=&quot;https://docs.celeryq.dev/en/stable/faq.html?highlight=windows#does-celery-support-windows&quot;&gt;dropped support for Windows&lt;/a&gt; in version 4, so while &lt;a href=&quot;https://stackoverflow.com/a/47331438/5717580&quot;&gt;you may still be able to get it to work&lt;/a&gt; on Windows, you’re better off using a different task queue, such as &lt;a href=&quot;https://huey.readthedocs.io/en/latest/index.html&quot;&gt;huey&lt;/a&gt; or &lt;a href=&quot;https://dramatiq.io/index.html&quot;&gt;Dramatiq&lt;/a&gt;, instead.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll focus on using Celery on UNIX systems, so if you’re trying to set up a distributed task queue on &lt;em&gt;Windows&lt;/em&gt;, then this might not be the right tutorial for you.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To receive tasks from your program and send results to a back end, Celery requires a &lt;a href=&quot;https://en.wikipedia.org/wiki/Message_broker&quot;&gt;message broker&lt;/a&gt; for communication. &lt;strong&gt;Redis&lt;/strong&gt; and &lt;strong&gt;RabbitMQ&lt;/strong&gt; are two message brokers that developers often use together with Celery.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll use &lt;a href=&quot;https://redis.io/&quot;&gt;Redis&lt;/a&gt; as the message broker. To challenge yourself, you can stray from the instructions and use &lt;a href=&quot;https://www.rabbitmq.com/&quot;&gt;RabbitMQ&lt;/a&gt; as a message broker instead.&lt;/p&gt;
&lt;p&gt;If you want to keep track of the results of your task runs, then you also need to set up a &lt;strong&gt;results back end&lt;/strong&gt; database.&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; Connecting Celery to a results back end is optional. Once you instruct Celery to run a task, it’ll do its duty whether you keep track of the task result or not.&lt;/p&gt;
&lt;p&gt;However, keeping a record of all task results is often helpful, especially if you’re distributing tasks to multiple queues. To persist information about task results, you need a database back end.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You can use &lt;a href=&quot;https://docs.celeryq.dev/en/latest/userguide/configuration.html#std-setting-result_backend&quot;&gt;many different databases&lt;/a&gt; to keep track of Celery task results. In this tutorial, you’ll work with &lt;a href=&quot;https://realpython.com/python-redis/&quot;&gt;Redis&lt;/a&gt; both as a message broker and as a results back end. By using Redis, you limit the dependencies that you need to install because it can take on both roles.&lt;/p&gt;
&lt;p&gt;You won’t do any work with the recorded task results in the scope of this tutorial. However, as a next step, you could inspect the results with the Redis &lt;a href=&quot;/ref/glossary/command-line-interface/&quot; class=&quot;ref-link&quot;&gt;command-line interface (CLI)&lt;/a&gt; or pull information into a dedicated page in your Django project.&lt;/p&gt;
&lt;h3 id=&quot;why-use-celery&quot;&gt;Why Use Celery?&lt;a class=&quot;headerlink&quot; href=&quot;#why-use-celery&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There are two main reasons why most developers want to start using Celery:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Offloading work&lt;/strong&gt; from your app to distributed processes that can run independently of your app&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scheduling task execution&lt;/strong&gt; at a specific time, sometimes as recurring events&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Celery is an excellent choice for both of these use cases. It defines itself as “a task queue with focus on real-time processing, while also supporting task scheduling” (&lt;a href=&quot;https://docs.celeryq.dev/en/stable/index.html&quot;&gt;Source&lt;/a&gt;). &lt;/p&gt;
&lt;p&gt;Even though both of these functionalities are part of Celery, they’re often addressed separately:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Celery workers&lt;/strong&gt; are worker processes that run tasks independently from one another and outside the context of your main service.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Celery beat&lt;/strong&gt; is a scheduler that orchestrates when to run tasks. You can use it to schedule periodic tasks as well.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Celery workers are the backbone of Celery. Even if you aim to schedule recurring tasks using Celery beat, a Celery worker will pick up your instructions and handle them at the scheduled time. What Celery beat adds to the mix is a time-based scheduler for Celery workers.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn how to integrate Celery with Django to perform operations asynchronously from the main execution &lt;a href=&quot;/ref/glossary/thread/&quot; class=&quot;ref-link&quot;&gt;thread&lt;/a&gt; of your app using Celery workers.&lt;/p&gt;
&lt;p&gt;You won’t tackle task scheduling with Celery beat in this tutorial, but once you understand the basics of Celery tasks, you’ll be well equipped to set up &lt;a href=&quot;https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html&quot;&gt;periodic tasks&lt;/a&gt; with Celery beat.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/asynchronous-tasks-with-django-and-celery/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/asynchronous-tasks-with-django-and-celery/ »&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>Digging Deeper Into Django Migrations</title>
      <id>https://realpython.com/digging-deeper-into-migrations/</id>
      <link href="https://realpython.com/digging-deeper-into-migrations/"/>
      <updated>2026-10-18T14:00:00+00:00</updated>
      <summary>Go beyond the basics of Django migrations: how they work under the hood, what the Django migrations table tracks, and what&#x27;s inside migration files.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You already understand the purpose of Django migrations and you’re familiar with fundamental usage patterns like creating and applying migrations. In this tutorial, you’ll dig deeper into the migration system and take a peek at some of its underlying mechanics, from the Django migrations table to the migration files themselves.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this article, you’ll know:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How Django keeps track of migrations&lt;/li&gt;
&lt;li&gt;How migrations know which database operations to perform&lt;/li&gt;
&lt;li&gt;How dependencies between migrations are defined&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you’ve wrapped your head around this part of the Django migration system, you’ll be well prepared to create your own custom migrations. Let’s jump right in where we left off!&lt;/p&gt;
&lt;p&gt;This article uses the &lt;code&gt;bitcoin_tracker&lt;/code&gt; Django project built in &lt;a href=&quot;https://realpython.com/django-migrations-a-primer/&quot;&gt;Django Migrations: A Primer&lt;/a&gt;. You can either re-create that project by working through that article or you can download the source code:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Download Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/django-migrations/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-django-migrations&quot; markdown&gt;Click here to download the code for the Django migrations project you’ll be using in this article.&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;the-django-migrations-table&quot;&gt;The Django Migrations Table&lt;a class=&quot;headerlink&quot; href=&quot;#the-django-migrations-table&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s recap how Django handles migrations. Assume that you’ve created a migration and then applied all available migrations with &lt;code&gt;python manage.py migrate&lt;/code&gt;.
If that command ran successfully, then your database tables now match your model’s definitions.&lt;/p&gt;
&lt;p&gt;What happens if you run that command again? Let’s try it out:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;manage.py&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;migrate
&lt;span class=&quot;go&quot;&gt;Operations to perform:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  Apply all migrations: admin, auth, contenttypes, historical_data, sessions&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Running migrations:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  No migrations to apply.&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.8f1dcd28e216.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;Nothing happened! Once a migration has been applied to a database, Django will not apply this migration to that particular database again. Ensuring that a migration is applied only once requires keeping track of the migrations that have been applied.&lt;/p&gt;
&lt;p&gt;Django uses a database table called &lt;code&gt;django_migrations&lt;/code&gt;. Django automatically creates this table in your database the first time you apply any migrations. For each migration that’s applied or faked, a new row is inserted into the table.&lt;/p&gt;
&lt;p&gt;For example, here’s what this table looks like in our &lt;code&gt;bitcoin_tracker&lt;/code&gt; project:&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;ID&lt;/th&gt;
&lt;th&gt;App&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Applied&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;code&gt;contenttypes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0001_initial&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.461496&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0001_initial&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.489948&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;&lt;code&gt;admin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0001_initial&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.508742&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;code&gt;admin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0002_logentry_remove...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.531390&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;&lt;code&gt;admin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0003_logentry_add_ac...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.564834&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;&lt;code&gt;contenttypes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0002_remove_content_...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.597186&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0002_alter_permissio...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.608705&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0003_alter_user_emai...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.628441&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0004_alter_user_user...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.646824&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0005_alter_user_last...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.661182&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0006_require_content...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.663664&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0007_alter_validator...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.679482&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0008_alter_user_user...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.699201&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0009_alter_user_last...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.718652&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0010_alter_group_nam...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.721038&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0011_update_proxy_pe...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.723517&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;&lt;code&gt;auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0012_alter_user_firs...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.724902&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18&lt;/td&gt;
&lt;td&gt;&lt;code&gt;historical_data&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0001_initial&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.726000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;19&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sessions&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0001_initial&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:23:21.734611&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;&lt;code&gt;historical_data&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0002_switch_to_decimals&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2019-02-05 20:30:11.337894&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, there is an entry for each applied migration. The table not only contains the migrations from our &lt;code&gt;historical_data&lt;/code&gt; app, but also the migrations from all other installed apps.&lt;/p&gt;
&lt;p&gt;The next time migrations are run, Django will skip the migrations listed in the database table. This means that, even if you manually change the file of a migration that has already been applied, Django will ignore these changes, as long as there’s already an entry for it in the database.&lt;/p&gt;
&lt;p&gt;You could trick Django into re-running a migration by deleting the corresponding row from the table, but this is rarely a good idea and can leave you with a broken migration system.&lt;/p&gt;
&lt;h2 id=&quot;the-migration-file&quot;&gt;The Migration File&lt;a class=&quot;headerlink&quot; href=&quot;#the-migration-file&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;What happens when you run &lt;code&gt;python manage.py makemigrations &amp;lt;appname&amp;gt;&lt;/code&gt;? Django looks for changes made to the models in your app &lt;code&gt;&amp;lt;appname&amp;gt;&lt;/code&gt;. If it finds any, like a model that has been added, then it creates a migration file in the &lt;code&gt;migrations&lt;/code&gt; subdirectory. This migration file contains a list of operations to bring your database schema in sync with your model definition.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/digging-deeper-into-migrations/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/digging-deeper-into-migrations/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s Mutable vs Immutable Types: What&#x27;s the Difference?</title>
      <id>https://realpython.com/python-mutable-vs-immutable-types/</id>
      <link href="https://realpython.com/python-mutable-vs-immutable-types/"/>
      <updated>2026-10-18T14:00:00+00:00</updated>
      <summary>Learn how Python mutable and immutable data types work internally and how you can use mutability or immutability to power your code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s mutable objects, such as lists and dictionaries, allow you to change their value or data directly without affecting their identity. In contrast, immutable objects, like tuples and strings, don’t allow in-place modifications. Instead, you’ll need to create new objects of the same type with different values.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The difference between &lt;strong&gt;mutable&lt;/strong&gt; and &lt;strong&gt;immutable&lt;/strong&gt; objects is that mutable objects can be modified, while immutable objects can’t be altered once created.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python lists&lt;/strong&gt; are mutable, allowing you to change, add, or remove elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Strings in Python&lt;/strong&gt; are immutable, meaning you can’t change their content after creation.&lt;/li&gt;
&lt;li&gt;To &lt;strong&gt;check if an object is mutable&lt;/strong&gt;, you can try altering its contents. If you succeed without an error, it’s mutable.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In Python, mutability is a characteristic that may profoundly influence your decision when choosing which data type to use for solving a programming problem. Therefore, you need to know how &lt;a href=&quot;/ref/glossary/mutable/&quot; class=&quot;ref-link&quot;&gt;mutable&lt;/a&gt; and &lt;a href=&quot;/ref/glossary/immutable/&quot; class=&quot;ref-link&quot;&gt;immutable&lt;/a&gt; objects work in Python.&lt;/p&gt;
&lt;p&gt;To dive smoothly into this fundamental Python topic, you should be familiar with how &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; work in Python. You should also know the basics of Python’s built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data types&lt;/a&gt;, such as &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-tuple/&quot;&gt;tuples&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;lists&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;sets&lt;/a&gt;, and others. Finally, knowing how &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; works in Python is also a good starting point.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Free Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-mutable-vs-immutable-types-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-mutable-vs-immutable-types-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to explore mutable vs immutable data types 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.8f1dcd28e216.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Python&#x27;s Mutable vs Immutable Types: What&#x27;s the Difference?” 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-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-mutable-vs-immutable-types/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #abe0e6;&quot; alt=&quot;Python&#x27;s Mutable vs Immutable Types: What&#x27;s the Difference?&quot; src=&quot;https://files.realpython.com/media/Mutable-and-Immutable-Data-Types-in-Python_Watermarked.2566c67a719d.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Mutable-and-Immutable-Data-Types-in-Python_Watermarked.2566c67a719d.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Mutable-and-Immutable-Data-Types-in-Python_Watermarked.2566c67a719d.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Mutable-and-Immutable-Data-Types-in-Python_Watermarked.2566c67a719d.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Mutable-and-Immutable-Data-Types-in-Python_Watermarked.2566c67a719d.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.8f1dcd28e216.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 position-relative&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-mutable-vs-immutable-types/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python&#x27;s Mutable vs Immutable Types: What&#x27;s the Difference?&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Find out how Python&#x27;s mutable and immutable types behave, and see how mutability shapes lists, tuples, dictionaries, and your own classes.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;mutability-vs-immutability&quot;&gt;Mutability vs Immutability&lt;a class=&quot;headerlink&quot; href=&quot;#mutability-vs-immutability&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In programming, you have an &lt;strong&gt;immutable object&lt;/strong&gt; if you can’t change the object’s &lt;a href=&quot;https://en.wikipedia.org/wiki/State_(computer_science)&quot;&gt;state&lt;/a&gt; after you’ve created it. In contrast, a &lt;strong&gt;mutable object&lt;/strong&gt; allows you to modify its internal state after creation. In short, whether you’re able to change an object’s state or contained data is what defines if that object is mutable or immutable.&lt;/p&gt;
&lt;p&gt;Immutable objects are common in &lt;a href=&quot;https://realpython.com/python-functional-programming/&quot;&gt;functional programming&lt;/a&gt;, while mutable objects are widely used in &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;. Because Python is a multiparadigm programming language, it provides mutable and immutable objects for you to choose from when solving a problem.&lt;/p&gt;
&lt;p&gt;To understand how mutable and immutable objects work in Python, you first need to understand a few related concepts. To kick things off, you’ll take a look at variables and objects.&lt;/p&gt;
&lt;h3 id=&quot;variables-and-objects&quot;&gt;Variables and Objects&lt;a class=&quot;headerlink&quot; href=&quot;#variables-and-objects&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Python, &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; don’t have an associated type or size, as they’re labels attached to objects in memory. They point to the memory position where concrete objects live. In other words, a Python variable is a name that &lt;em&gt;refers to&lt;/em&gt; or holds a &lt;em&gt;reference to&lt;/em&gt; a concrete object. In contrast, Python &lt;strong&gt;objects&lt;/strong&gt; are concrete pieces of information that live in specific memory positions on your computer.&lt;/p&gt;
&lt;p&gt;The main takeaway here is that variables and objects are two different animals in Python:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variables&lt;/strong&gt; hold references to objects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Objects&lt;/strong&gt; live in concrete memory positions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both concepts are independent of each other. However, they’re closely related. Once you’ve created a variable with an &lt;a href=&quot;https://realpython.com/python-assignment-operator/&quot;&gt;assignment statement&lt;/a&gt;, then you can access the referenced object throughout your code by using the variable name. If the referenced object is mutable, then you can also perform &lt;strong&gt;mutations&lt;/strong&gt; on it through the variable. Mutability or immutability is intrinsic to objects rather than to variables.&lt;/p&gt;
&lt;p&gt;However, if the referenced object is immutable, then you won’t be able to change its internal state or contained data. You’ll just be able to make your variable reference a different object that, in Python, may or may not be of the same type as your original object.&lt;/p&gt;
&lt;p&gt;If you don’t have a reference (variable) to an object, then you can’t access that object in your code. If you lose or remove all the references to a given object, then Python will &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-garbage-collection&quot;&gt;garbage-collect&lt;/a&gt; that object, freeing the memory for later use.&lt;/p&gt;
&lt;p&gt;Now that you know that there are differences between variables and objects, you need to learn that all Python objects have three core properties: identity, type, and value.&lt;/p&gt;
&lt;h3 id=&quot;objects-value-identity-and-type&quot;&gt;Objects, Value, Identity, and Type&lt;a class=&quot;headerlink&quot; href=&quot;#objects-value-identity-and-type&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Python, everything is an object. For example, &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&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;, and &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;modules&lt;/a&gt; are all objects. Every Python object has three core characteristics that define it at a foundational level. These characteristics are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Value&lt;/li&gt;
&lt;li&gt;Identity&lt;/li&gt;
&lt;li&gt;Type&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Arguably, the &lt;strong&gt;value&lt;/strong&gt; is probably the most familiar object characteristic that you’ve dealt with. An object’s value consists of the concrete piece or pieces of &lt;strong&gt;data&lt;/strong&gt; contained in the object itself. A classic example is a numeric value like an &lt;a href=&quot;https://realpython.com/python-numbers/#integers&quot;&gt;integer&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-numbers/#floating-point-numbers&quot;&gt;floating-point&lt;/a&gt; number:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;mi&quot;&gt;42&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;isinstance&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;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3.14&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;isinstance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;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.8f1dcd28e216.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;These numeric values, &lt;code&gt;42&lt;/code&gt; and &lt;code&gt;3.14&lt;/code&gt;, are both objects. The first number is an &lt;a href=&quot;/ref/glossary/instance/&quot; class=&quot;ref-link&quot;&gt;instance&lt;/a&gt; of the built-in &lt;a href=&quot;https://docs.python.org/3/builtins/functions.html#int&quot;&gt;&lt;code&gt;int&lt;/code&gt;&lt;/a&gt; class, while the second is an instance of &lt;a href=&quot;https://docs.python.org/3/builtins/functions.html#float&quot;&gt;&lt;code&gt;float&lt;/code&gt;&lt;/a&gt;. In both examples, you confirm the object’s type using the built-in &lt;a href=&quot;https://realpython.com/what-does-isinstance-do-in-python/&quot;&gt;&lt;code&gt;isinstance()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-mutable-vs-immutable-types/ »&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>Django Migrations: A Primer</title>
      <id>https://realpython.com/django-migrations-a-primer/</id>
      <link href="https://realpython.com/django-migrations-a-primer/"/>
      <updated>2026-10-18T14:00:00+00:00</updated>
      <summary>Get comfortable with Django migrations: create database tables without writing SQL, and keep your database in step as your models change.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Since version 1.7, Django has come with built-in support for database migrations. In &lt;a href=&quot;https://realpython.com/get-started-with-django-1/&quot;&gt;Django&lt;/a&gt;, database migrations usually go hand in hand with models: whenever you code up a new model, you also generate a migration to create the necessary table in the database. However, migrations can do much more.&lt;/p&gt;
&lt;p&gt;In this article, you’ll get comfortable with Django migrations and learn the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to create database tables without writing any SQL&lt;/li&gt;
&lt;li&gt;How to automatically modify your database after you changed your models&lt;/li&gt;
&lt;li&gt;How to revert changes made to your database&lt;/li&gt;
&lt;/ul&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/django-resources/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-django-resources&quot; markdown&gt;Click here to get access to a free Django Learning Resources Guide (PDF)&lt;/a&gt; that shows you tips and tricks as well as common pitfalls to avoid when building Python + Django web applications.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;the-problems-that-migrations-solve&quot;&gt;The Problems That Migrations Solve&lt;a class=&quot;headerlink&quot; href=&quot;#the-problems-that-migrations-solve&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you are new to Django or web development in general, you might not be familiar with the concept of database migrations, and it might not seem obvious why they’re a good idea.&lt;/p&gt;
&lt;p&gt;First, let’s quickly define a couple of terms to make sure everybody is on the same page. Django is designed to work with a &lt;a href=&quot;https://en.wikipedia.org/wiki/Relational_database&quot;&gt;relational
database&lt;/a&gt;, stored in a relational database management system like &lt;a href=&quot;https://www.postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt;, &lt;a href=&quot;https://www.mysql.com/&quot;&gt;MySQL&lt;/a&gt;, or &lt;a href=&quot;https://www.sqlite.org/index.html&quot;&gt;SQLite&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In a relational database, data is organized in tables. A database table has a certain number of columns, but it can have any number of rows. Each column has a specific datatype, like a string of a certain maximum length or a positive integer. The description of all tables with their columns and their respective datatypes is called a database schema.&lt;/p&gt;
&lt;p&gt;All database systems supported by Django use the language SQL to create, read, update and delete data in a relational database. SQL is also used to create, change, and delete the database tables themselves.&lt;/p&gt;
&lt;p&gt;Working directly with SQL can be quite cumbersome, so to make your life easier, Django comes with an object-relational mapper, or ORM for short. The ORM maps the relational database to the world of &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object oriented programming&lt;/a&gt;. Instead of defining database tables in SQL, you write &lt;a href=&quot;https://docs.djangoproject.com/en/stable/topics/db/models/&quot;&gt;Django models&lt;/a&gt; in Python. Your models define database fields, which correspond to the columns in their database tables.&lt;/p&gt;
&lt;p&gt;Here’s an example of how a Django model &lt;a href=&quot;/ref/glossary/class/&quot; class=&quot;ref-link&quot;&gt;class&lt;/a&gt; is mapped to a database table:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/model_to_schema.4e4b8506dc26.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/model_to_schema.4e4b8506dc26.png&quot; width=&quot;1338&quot; height=&quot;546&quot; srcset=&quot;/cdn-cgi/image/width=334,format=auto/https://files.realpython.com/media/model_to_schema.4e4b8506dc26.png 334w, /cdn-cgi/image/width=446,format=auto/https://files.realpython.com/media/model_to_schema.4e4b8506dc26.png 446w, /cdn-cgi/image/width=669,format=auto/https://files.realpython.com/media/model_to_schema.4e4b8506dc26.png 669w, /cdn-cgi/image/width=1338,format=auto/https://files.realpython.com/media/model_to_schema.4e4b8506dc26.png 1338w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Django Model to Database Schema&quot; data-asset=&quot;929&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;But just defining a model class in a Python file does not make a database table magically appear out of nowhere. Creating the database tables to store your Django models is the job of a database migration. Additionally, whenever you make a change to your models, like adding a field, the database has to be changed too. Migrations handle that as well.&lt;/p&gt;
&lt;p&gt;Here are a few ways Django migrations make your life easier.&lt;/p&gt;
&lt;h3 id=&quot;making-database-changes-without-sql&quot;&gt;Making Database Changes Without SQL&lt;a class=&quot;headerlink&quot; href=&quot;#making-database-changes-without-sql&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Without migrations, you would have to connect to your database and type in a bunch of SQL commands or use a graphical tool like &lt;a href=&quot;https://www.phpmyadmin.net/&quot;&gt;PHPMyAdmin&lt;/a&gt; to modify the database schema every time you wanted to change your model definition.&lt;/p&gt;
&lt;p&gt;In Django, migrations are primarily written in Python, so you don’t have to know any SQL unless you have really advanced use cases.&lt;/p&gt;
&lt;h3 id=&quot;avoiding-repetition&quot;&gt;Avoiding Repetition&lt;a class=&quot;headerlink&quot; href=&quot;#avoiding-repetition&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Creating a model and then writing SQL to create the database tables for it would be repetitive.&lt;/p&gt;
&lt;p&gt;Migrations are generated from your models, making sure you &lt;a href=&quot;https://en.wikipedia.org/wiki/Don%27t_repeat_yourself&quot;&gt;don’t repeat yourself&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;ensuring-model-definitions-and-the-database-schema-in-sync&quot;&gt;Ensuring Model Definitions and the Database Schema in Sync&lt;a class=&quot;headerlink&quot; href=&quot;#ensuring-model-definitions-and-the-database-schema-in-sync&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Usually, you have multiple instances of your database, for example one database for each developer in your team, a database for testing and a database with live data.&lt;/p&gt;
&lt;p&gt;Without migrations, you will have to perform any schema changes on each one of your database, and you will have to keep track which changes have already been made to which database.&lt;/p&gt;
&lt;p&gt;With Django Migrations, you can easily keep multiple databases in sync with your models.&lt;/p&gt;
&lt;h3 id=&quot;tracking-database-schema-change-in-version-control&quot;&gt;Tracking Database Schema Change in Version Control&lt;a class=&quot;headerlink&quot; href=&quot;#tracking-database-schema-change-in-version-control&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/django-migrations-a-primer/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/django-migrations-a-primer/ »&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: Writing Comments in Python (Guide)</title>
      <id>https://realpython.com/quizzes/python-comments-guide/</id>
      <link href="https://realpython.com/quizzes/python-comments-guide/"/>
      <updated>2026-10-18T12:00:00+00:00</updated>
      <summary>Test your understanding of how to write clean, useful Python comments, from basic syntax and docstrings to the comment types you should avoid.</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-comments-guide/&quot;&gt;Writing Comments in Python (Guide)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to write comments and docstrings in
Python, when comments help you and your teammates, and which kinds of comments to avoid,
like W.E.T., smelly, and rude ones.&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 Best IDEs and Code Editors for Python (Guide)</title>
      <id>https://realpython.com/python-ides-code-editors-guide/</id>
      <link href="https://realpython.com/python-ides-code-editors-guide/"/>
      <updated>2026-10-17T14:00:00+00:00</updated>
      <summary>Compare the best Python IDEs and code editors side by side, with free picks for beginners and pro tools for data science and AI-assisted coding.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Choosing the best IDE or code editor for Python means weighing your skill level, project type, and workflow in a landscape that has changed dramatically in recent years. AI-first editors have arrived, and well-established tools have added AI integrations. This guide cuts through the noise and maps each tool to the situations where it fits best.&lt;/p&gt;
&lt;p&gt;The Python ecosystem now spans six categories of coding tools. You’ll walk through each one, learn what distinguishes the tools within each category, and end with a flowchart that maps common scenarios to concrete recommendations.&lt;/p&gt;
&lt;p&gt;Here’s a quick overview of the situations you’re most likely to encounter and the tools that fit each one:&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;Situation&lt;/th&gt;
&lt;th&gt;Tools to Consider&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Learning or teaching Python&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-thonny/&quot;&gt;Thonny&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Professional development (GUI)&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-development-visual-studio-code/&quot;&gt;Visual Studio Code&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/pycharm-guide/&quot;&gt;PyCharm&lt;/a&gt;, GitHub Codespaces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Professional development (terminal)&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;/ref/code-editors-ides/neovim/&quot; class=&quot;ref-link&quot;&gt;Neovim&lt;/a&gt; (&lt;a href=&quot;/ref/code-editors-ides/vim/&quot; class=&quot;ref-link&quot;&gt;Vim&lt;/a&gt;), &lt;a href=&quot;https://realpython.com/emacs-the-best-python-editor/&quot;&gt;Emacs&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data science or machine learning&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/using-jupyterlab/&quot;&gt;JupyterLab&lt;/a&gt;, &lt;a href=&quot;/ref/tools/google-colab/&quot; class=&quot;ref-link&quot;&gt;Google Colab&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/marimo-notebook/&quot;&gt;marimo&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/spyder-ide/&quot;&gt;Spyder&lt;/a&gt;, &lt;a href=&quot;/ref/code-editors-ides/positron/&quot; class=&quot;ref-link&quot;&gt;Positron&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-assisted coding&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/courses/tips-using-ai-coding-editor-cursor/&quot;&gt;Cursor&lt;/a&gt;, &lt;a href=&quot;/ref/ai-coding-tools/kiro/&quot; class=&quot;ref-link&quot;&gt;Kiro&lt;/a&gt;, &lt;a href=&quot;/ref/ai-coding-tools/zed/&quot; class=&quot;ref-link&quot;&gt;Zed&lt;/a&gt;, PyCharm with &lt;a href=&quot;/ref/ai-coding-tools/jetbrains-ai-assistant/&quot; class=&quot;ref-link&quot;&gt;JetBrains AI Assistant&lt;/a&gt;, or &lt;a href=&quot;/ref/code-editors-ides/visual-studio-code/&quot; class=&quot;ref-link&quot;&gt;VS Code&lt;/a&gt; with &lt;a href=&quot;https://realpython.com/github-copilot-python/&quot;&gt;GitHub Copilot&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coding in the browser with no local setup&lt;/td&gt;
&lt;td&gt;GitHub Codespaces, Google Colab, &lt;a href=&quot;https://realpython.com/search?kind=exercise&quot;&gt;Real Python Exercises&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;With this overview, you’re ready to explore the main features of these tools. First, you’ll get a quick peek at what makes a good code editor for Python.&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/python-ides-code-editors-guide-cheatsheet/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-ides-code-editors-guide-cheatsheet&quot; markdown&gt;Click here to download your free Python IDEs and code editors cheat sheet (PDF)&lt;/a&gt; and match the right tool to your skill level, project type, and workflow.&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.8f1dcd28e216.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 “The Best IDEs and Code Editors for Python (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-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/python-ides-code-editors-guide/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #ffc973;&quot; alt=&quot;A person with a clipboard inspects screens labeled BEGINNER, PRO IDE, and DATA SCIENCE alongside a terminal prompt and a cloud, beneath a ribbon conveyor with a Python logo.&quot; src=&quot;https://files.realpython.com/media/Python-IDEs-and-Code-Editors-Guide_Watermarked.b974bcfb128f.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Python-IDEs-and-Code-Editors-Guide_Watermarked.b974bcfb128f.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Python-IDEs-and-Code-Editors-Guide_Watermarked.b974bcfb128f.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Python-IDEs-and-Code-Editors-Guide_Watermarked.b974bcfb128f.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Python-IDEs-and-Code-Editors-Guide_Watermarked.b974bcfb128f.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.8f1dcd28e216.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 position-relative&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-ides-code-editors-guide/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;The Best IDEs and Code Editors for Python (Guide)&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your grasp of Python IDEs and code editors, from beginner-friendly tools to notebooks, AI-first editors, and cloud workspaces.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;what-makes-a-good-python-code-editor&quot;&gt;What Makes a Good Python Code Editor?&lt;a class=&quot;headerlink&quot; href=&quot;#what-makes-a-good-python-code-editor&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you dive into specific tools, it helps to know what features matter when choosing a Python &lt;a href=&quot;/ref/glossary/ide/&quot; class=&quot;ref-link&quot;&gt;integrated development environment (IDE)&lt;/a&gt; or code editor.&lt;/p&gt;
&lt;p&gt;Most general-purpose Python editors provide these basic features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Syntax highlighting:&lt;/strong&gt; Color-codes keywords, &lt;a href=&quot;/ref/builtin-types/str/&quot; class=&quot;ref-link&quot;&gt;strings&lt;/a&gt;, and &lt;a href=&quot;/ref/glossary/identifier/&quot; class=&quot;ref-link&quot;&gt;identifiers&lt;/a&gt; so you can scan &lt;a href=&quot;/ref/glossary/source-code/&quot; class=&quot;ref-link&quot;&gt;code&lt;/a&gt; at a glance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code completion:&lt;/strong&gt; Autocompletes names as you type, drawing not just on the current file but also on your installed packages and type stubs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linting and &lt;a href=&quot;/ref/best-practices/type-checking/&quot; class=&quot;ref-link&quot;&gt;type checking&lt;/a&gt;:&lt;/strong&gt; Flags likely bugs before you run the code, using tools like &lt;a href=&quot;/ref/tools/pylint/&quot; class=&quot;ref-link&quot;&gt;Pylint&lt;/a&gt;, &lt;a href=&quot;/ref/tools/ruff/&quot; class=&quot;ref-link&quot;&gt;Ruff&lt;/a&gt;, or &lt;a href=&quot;/ref/tools/mypy/&quot; class=&quot;ref-link&quot;&gt;mypy&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integrated debugging:&lt;/strong&gt; Lets you step through code, inspect &lt;a href=&quot;/ref/glossary/variable/&quot; class=&quot;ref-link&quot;&gt;variables&lt;/a&gt;, and set breakpoints without leaving the editor.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Virtual environment and package management awareness:&lt;/strong&gt; Detects active &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environments&lt;/a&gt; automatically and uses the right Python &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt; and &lt;a href=&quot;/ref/glossary/package/&quot; class=&quot;ref-link&quot;&gt;packages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/ref/best-practices/code-formatting/&quot; class=&quot;ref-link&quot;&gt;Code formatting&lt;/a&gt;:&lt;/strong&gt; Keeps your code consistently styled using formatters like &lt;a href=&quot;/ref/tools/black/&quot; class=&quot;ref-link&quot;&gt;Black&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/ruff-python/&quot;&gt;Ruff&lt;/a&gt;, with no manual effort.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Other features are less universal, but they’ve become standard in modern professional workflows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/ref/tools/git/&quot; class=&quot;ref-link&quot;&gt;Git&lt;/a&gt; integration:&lt;/strong&gt; Staging, committing, and reviewing diffs in place saves you the context switching of a separate Git client.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AI assistance:&lt;/strong&gt; Ranges from inline completions to multi-file chat and agentic refactoring, and from lightweight extensions to editors designed around AI.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nowadays, the level of &lt;a href=&quot;/ref/ai-coding-glossary/ai/&quot; class=&quot;ref-link&quot;&gt;AI&lt;/a&gt; integration you want is one of the main axes for choosing a coding tool. If deep AI integration is what you’re looking for, then you can skip ahead to the section on &lt;a href=&quot;#ai-first-editors&quot;&gt;AI-first editors&lt;/a&gt;. However, if you’re new to Python, then you’ll want to avoid tooling complexity, and the &lt;a href=&quot;#beginner-friendly-ides-and-editors&quot;&gt;beginner-friendly IDEs and editors&lt;/a&gt; in the next section are a better starting point.&lt;/p&gt;
&lt;h2 id=&quot;beginner-friendly-ides-and-editors&quot;&gt;Beginner-Friendly IDEs and Editors&lt;a class=&quot;headerlink&quot; href=&quot;#beginner-friendly-ides-and-editors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’re just starting with Python, the worst thing an editor can do is get in your way before you write a single line of code. The two tools in this category are designed around that principle: minimal setup, clear feedback, and no configuration.&lt;/p&gt;
&lt;h3 id=&quot;idle&quot;&gt;IDLE&lt;a class=&quot;headerlink&quot; href=&quot;#idle&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/ref/glossary/idle/&quot; class=&quot;ref-link&quot;&gt;&lt;strong&gt;IDLE&lt;/strong&gt;&lt;/a&gt; is the standard Python IDE and ships with the official Python installer on Windows and macOS. You can launch it from the &lt;em&gt;Start&lt;/em&gt; menu on Windows and from the &lt;em&gt;Launchpad&lt;/em&gt; on macOS.&lt;/p&gt;
&lt;p&gt;On &lt;a href=&quot;/ref/computer-science-glossary/linux/&quot; class=&quot;ref-link&quot;&gt;Linux&lt;/a&gt;, you can install IDLE separately with the &lt;code&gt;sudo apt install idle&lt;/code&gt; command on Ubuntu or Debian. Then run &lt;code&gt;idle&lt;/code&gt; in the terminal to start the Python shell with a code editor attached. There’s nothing to configure and no account to create.&lt;/p&gt;
&lt;p&gt;Here’s where to read the docs, grab the installer, and go deeper with Real Python’s IDLE resources:&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;Resource&lt;/th&gt;
&lt;th&gt;Link&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Documentation&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://docs.python.org/3/library/idle.html&quot;&gt;docs.python.org/idle&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Download or install&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://www.python.org/downloads/&quot;&gt;python.org/downloads&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real Python&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;Getting Started With Python IDLE&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/courses/starting-python-idle/&quot;&gt;Starting With Python IDLE&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;The editor includes syntax highlighting, a basic debugger, and an interactive &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt; that lets you test code ideas immediately. The interface is minimal by design. You get the essentials and nothing more.&lt;/p&gt;
&lt;p&gt;IDLE is a practical choice for working through the Python documentation, experimenting with short &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;scripts&lt;/a&gt;, or teaching a single concept in a classroom setting where you can’t rely on students having anything else installed.&lt;/p&gt;
&lt;p&gt;Here’s IDLE’s main interface, with its REPL and editor window side by side:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/idle-ide-interface.957b75287a8e.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/idle-ide-interface.957b75287a8e.png&quot; width=&quot;3024&quot; height=&quot;1964&quot; srcset=&quot;/cdn-cgi/image/width=756,format=auto/https://files.realpython.com/media/idle-ide-interface.957b75287a8e.png 756w, /cdn-cgi/image/width=1008,format=auto/https://files.realpython.com/media/idle-ide-interface.957b75287a8e.png 1008w, /cdn-cgi/image/width=1512,format=auto/https://files.realpython.com/media/idle-ide-interface.957b75287a8e.png 1512w, /cdn-cgi/image/width=3024,format=auto/https://files.realpython.com/media/idle-ide-interface.957b75287a8e.png 3024w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;IDLE IDE Interface&quot; data-asset=&quot;6841&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;The IDLE Interface&lt;/figcaption&gt;&lt;/figure&gt;

&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-ides-code-editors-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>Python&#x27;s Instance, Class, and Static Methods Demystified</title>
      <id>https://realpython.com/instance-class-and-static-methods-demystified/</id>
      <link href="https://realpython.com/instance-class-and-static-methods-demystified/"/>
      <updated>2026-10-17T14:00:00+00:00</updated>
      <summary>Compare instance methods vs class methods vs static methods in Python, and learn when each one earns its place in your code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Instance, class, and static methods each serve a distinct role in Python, and knowing when to use one over another is key to writing clean, maintainable code. Instance methods operate on individual objects using &lt;code&gt;self&lt;/code&gt;, while class methods use &lt;code&gt;cls&lt;/code&gt; to access class-level data. Static methods, on the other hand, provide organizational structure without relying on class or instance state.&lt;/p&gt;
&lt;p&gt;When you understand the differences between these three method types, you’ll be in a better spot to know when to write an instance method, class method, or a static method. Ultimately, this’ll help you design better maintainable object-oriented Python code.&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;Instance methods&lt;/strong&gt; access the state of a &lt;strong&gt;specific object&lt;/strong&gt; through the &lt;strong&gt;&lt;code&gt;self&lt;/code&gt;&lt;/strong&gt; parameter.&lt;/li&gt;
&lt;li&gt;You create &lt;strong&gt;class methods&lt;/strong&gt; with the &lt;strong&gt;&lt;code&gt;@classmethod&lt;/code&gt;&lt;/strong&gt; &lt;a href=&quot;/ref/glossary/decorator/&quot; class=&quot;ref-link&quot;&gt;decorator&lt;/a&gt; and use them for operations that involve &lt;strong&gt;class-level data&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You use &lt;strong&gt;static methods&lt;/strong&gt; for &lt;strong&gt;utility functionality&lt;/strong&gt; that doesn’t need class or instance data, and you create them with the &lt;strong&gt;&lt;code&gt;@staticmethod&lt;/code&gt;&lt;/strong&gt; decorator.&lt;/li&gt;
&lt;li&gt;Using class methods and static methods in your classes can &lt;strong&gt;improve class design&lt;/strong&gt; and code maintainability.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Keep reading to see all three method types in action. You’ll even bake some digital pizza while working on a real-world example with all three method types in a &lt;code&gt;Pizza&lt;/code&gt; class.
If you develop an intuitive understanding for their differences, you’ll be able to write &lt;a href=&quot;/ref/glossary/oop/&quot; class=&quot;ref-link&quot;&gt;object-oriented&lt;/a&gt; Python code that communicates its intent more clearly and is easier to maintain in the long run.&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/instance-class-and-static-methods-demystified-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-instance-class-and-static-methods-demystified-code&quot; markdown&gt;Click here to download the free sample code &lt;/a&gt; you’ll use to learn about instance, class, and static methods 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.8f1dcd28e216.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Python&#x27;s Instance, Class, and Static Methods Demystified” 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-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/instance-class-and-static-methods-demystified/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #b9abe6;&quot; alt=&quot;Python classmethods, staticmethods, and instance methods&quot; src=&quot;https://files.realpython.com/media/Pythons-Instance-Class-and-Static-Methods-Demystified_Watermarked.5bce71bc29d0.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-Instance-Class-and-Static-Methods-Demystified_Watermarked.5bce71bc29d0.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Pythons-Instance-Class-and-Static-Methods-Demystified_Watermarked.5bce71bc29d0.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Pythons-Instance-Class-and-Static-Methods-Demystified_Watermarked.5bce71bc29d0.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Pythons-Instance-Class-and-Static-Methods-Demystified_Watermarked.5bce71bc29d0.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.8f1dcd28e216.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 position-relative&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/instance-class-and-static-methods-demystified/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python&#x27;s Instance, Class, and Static Methods Demystified&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of instance, class, and static methods in Python. By working through this quiz, you&#x27;ll revisit the differences between these methods and how to use them effectively in your Python code.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;compare-instance-methods-vs-class-methods-vs-static-methods&quot;&gt;Compare Instance Methods vs Class Methods vs Static Methods&lt;a class=&quot;headerlink&quot; href=&quot;#compare-instance-methods-vs-class-methods-vs-static-methods&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’re here for a quick reminder of how the three method types differ from one another, then consider the following overview that compares them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Instance methods&lt;/strong&gt; use a &lt;code&gt;self&lt;/code&gt; parameter pointing to an &lt;a href=&quot;/ref/glossary/instance/&quot; class=&quot;ref-link&quot;&gt;instance&lt;/a&gt; of the &lt;a href=&quot;/ref/glossary/class/&quot; class=&quot;ref-link&quot;&gt;class&lt;/a&gt;. They can access and modify instance state through &lt;code&gt;self&lt;/code&gt; and class state through &lt;code&gt;self.__class__&lt;/code&gt;. These are the most common methods in Python classes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Class methods&lt;/strong&gt; use a &lt;code&gt;cls&lt;/code&gt; parameter pointing to the class itself. They can modify class-level state through &lt;code&gt;cls&lt;/code&gt;, but they can’t modify individual instance state.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Static methods&lt;/strong&gt; don’t take &lt;code&gt;self&lt;/code&gt; or &lt;code&gt;cls&lt;/code&gt; parameters. They can’t modify instance or class state directly, and you’ll mainly use them for organizational purposes and namespacing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you need to revisit information quickly, there’s nothing quite like a table. So here are the most important aspects of the three different types of methods in Python classes summed up in a table:&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;Type&lt;/th&gt;
&lt;th&gt;Decorator&lt;/th&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;Instance Access&lt;/th&gt;
&lt;th&gt;Class Access&lt;/th&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Instance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None needed&lt;/td&gt;
&lt;td&gt;&lt;code&gt;self&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Operations on individual instances.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Class&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;@classmethod&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Factory methods, alternative constructors, or any method that deals with class-level data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Static&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;@staticmethod&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No &lt;code&gt;self&lt;/code&gt; or &lt;code&gt;cls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Utility methods that don’t need instance or class data.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;That’s enough super-condensed, repetitive reference information! If you want to know what all of this means in practice, and you like to learn by running code snippets and reasoning about them, then keep on reading.&lt;/p&gt;
&lt;p&gt;Next, you’ll explore the differences between instance, class, and static methods in a somewhat abstract code example. Abstract you say? Don’t worry—it involves runnable code, and it’s there to set the stage for a more practical example later on.&lt;/p&gt;
&lt;h2 id=&quot;gain-insight-through-an-abstract-example&quot;&gt;Gain Insight Through an Abstract Example&lt;a class=&quot;headerlink&quot; href=&quot;#gain-insight-through-an-abstract-example&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To get warmed up, you’ll write a small Python file called &lt;code&gt;demo.py&lt;/code&gt; with a bare-bones Python class that contains stripped-down examples of all three method types:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Python&lt;/span&gt;
    &lt;span class=&quot;me-2&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Filename: &lt;/span&gt;&lt;code style=&quot;color: inherit; background: inherit;&quot;&gt;demo.py&lt;/code&gt;&lt;/span&gt;
    &lt;div class=&quot;noselect&quot;&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div 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;k&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DemoClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;instance_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;instance method called&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@classmethod&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;class_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;class method called&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@staticmethod&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;static_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;static method called&quot;&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.8f1dcd28e216.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;demo.py&lt;/code&gt;, you create &lt;code&gt;DemoClass&lt;/code&gt;—a descriptively named custom class with the sole purpose of demoing the differences between instance methods, class methods, and static methods.&lt;/p&gt;
&lt;p&gt;Consequently, you also implement one of each of the three method types and name them accordingly. They each return a &lt;a href=&quot;https://realpython.com/python-tuple/&quot;&gt;tuple&lt;/a&gt; containing information to help you trace what’s going on, as well as the &lt;a href=&quot;/ref/glossary/argument/&quot; class=&quot;ref-link&quot;&gt;arguments&lt;/a&gt; the method received, such as &lt;code&gt;self&lt;/code&gt; and &lt;code&gt;cls&lt;/code&gt;. The output will help you understand which &lt;a href=&quot;/ref/glossary/object/&quot; class=&quot;ref-link&quot;&gt;objects&lt;/a&gt; each of the methods can access.&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; Naming these parameters &lt;code&gt;self&lt;/code&gt; and &lt;code&gt;cls&lt;/code&gt; is just a convention—but it’s a strong one in the Python community! You could name them &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; and get the same result. However, if you stray from the convention, then you may get disapproving looks from your coworkers or anyone reading your code.&lt;/p&gt;
&lt;p&gt;For functionality, all that matters is that you position them first in the parameter list for the method. For maintainability, sanity, and out of respect for others, you should always use &lt;code&gt;self&lt;/code&gt; and &lt;code&gt;cls&lt;/code&gt; in the classes you define.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now it’s time to call these demo methods in a new &lt;a href=&quot;/ref/glossary/repl/&quot; class=&quot;ref-link&quot;&gt;REPL&lt;/a&gt; session. Import &lt;code&gt;DemoClass&lt;/code&gt; and create an instance of it, then start by calling the &lt;strong&gt;instance method&lt;/strong&gt;:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;demo&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DemoClass&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;obj&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DemoClass&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;obj&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instance_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;(&#x27;instance method called&#x27;, &amp;lt;demo.DemoClass object at 0x100a30d70&amp;gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; 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.8f1dcd28e216.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 output confirms that &lt;code&gt;.instance_method()&lt;/code&gt; has access to the object instance through the &lt;code&gt;self&lt;/code&gt; argument. Python prints the object instance as &lt;code&gt;&amp;lt;demo.DemoClass object at 0x100a30d70&amp;gt;&lt;/code&gt;. When you call the instance method, Python replaces the &lt;code&gt;self&lt;/code&gt; argument with the instance object, &lt;code&gt;obj&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Instance methods can also access the class itself through the &lt;code&gt;self.__class__&lt;/code&gt; attribute. This makes instance methods powerful in terms of access restrictions. They can modify state on the object instance &lt;em&gt;and&lt;/em&gt; on the class itself.&lt;/p&gt;
&lt;p&gt;Next, you can try out the &lt;strong&gt;class method&lt;/strong&gt;:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/instance-class-and-static-methods-demystified/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Histogram Plotting: NumPy, Matplotlib, pandas &amp; Seaborn</title>
      <id>https://realpython.com/python-histograms/</id>
      <link href="https://realpython.com/python-histograms/"/>
      <updated>2026-10-17T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll be equipped to make production-quality, presentation-ready Python histogram plots with a range of choices and features.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In this tutorial, you’ll be equipped to make production-quality, presentation-ready Python histogram plots with a range of choices and features.&lt;/p&gt;
&lt;p&gt;If you have introductory to intermediate knowledge in &lt;a href=&quot;https://realpython.com/python-statistics/&quot;&gt;Python and statistics&lt;/a&gt;, then you can use this article as a one-stop shop for building and plotting histograms in Python using libraries from its scientific stack, including NumPy, Matplotlib, &lt;a href=&quot;https://realpython.com/pandas-python-explore-dataset/&quot;&gt;pandas&lt;/a&gt;, and Seaborn.&lt;/p&gt;
&lt;p&gt;A histogram is a great tool for quickly assessing a &lt;a href=&quot;https://en.wikipedia.org/wiki/Probability_distribution&quot;&gt;probability distribution&lt;/a&gt; that is intuitively understood by almost any audience.  Python offers a handful of different options for building and plotting histograms.  Most people know a histogram by its graphical representation, which is similar to a bar graph:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/commute_times.621e5b1ce062.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block w-75&quot; src=&quot;https://files.realpython.com/media/commute_times.621e5b1ce062.png&quot; width=&quot;1152&quot; height=&quot;888&quot; srcset=&quot;/cdn-cgi/image/width=288,format=auto/https://files.realpython.com/media/commute_times.621e5b1ce062.png 288w, /cdn-cgi/image/width=384,format=auto/https://files.realpython.com/media/commute_times.621e5b1ce062.png 384w, /cdn-cgi/image/width=576,format=auto/https://files.realpython.com/media/commute_times.621e5b1ce062.png 576w, /cdn-cgi/image/width=1152,format=auto/https://files.realpython.com/media/commute_times.621e5b1ce062.png 1152w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Histogram of commute times for 1000 commuters&quot; data-asset=&quot;538&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;This article will guide you through creating plots like the one above as well as more complex ones.  Here’s what you’ll cover:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Building histograms in pure Python, without use of third party libraries&lt;/li&gt;
&lt;li&gt;Constructing histograms with NumPy to summarize the underlying data&lt;/li&gt;
&lt;li&gt;Plotting the resulting histogram with Matplotlib, pandas, and Seaborn&lt;/li&gt;
&lt;/ul&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; Short on time? &lt;a href=&quot;https://realpython.com/bonus/histograms-cheatsheet/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-histograms-cheatsheet&quot; markdown&gt;Click here to get access to a free two-page Python histograms cheat sheet&lt;/a&gt; that summarizes the techniques explained in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;histograms-in-pure-python&quot;&gt;Histograms in Pure Python&lt;a class=&quot;headerlink&quot; href=&quot;#histograms-in-pure-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you are preparing to plot a histogram, it is simplest to not think in terms of bins but rather to report how many times each value appears (a frequency table).  A Python &lt;a href=&quot;https://docs.python.org/3/tutorial/datastructures.html#dictionaries&quot;&gt;dictionary&lt;/a&gt; is well-suited for this task:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;c1&quot;&gt;# Need not be sorted, necessarily&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;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&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;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;23&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;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count_elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;dict&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;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Tally elements from `seq`.&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;hist&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;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq&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;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hist&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;counted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&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;counted&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;{0: 1, 1: 3, 2: 1, 3: 1, 7: 2, 23: 1}&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.8f1dcd28e216.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;&lt;code&gt;count_elements()&lt;/code&gt; returns a &lt;a href=&quot;/ref/glossary/dictionary/&quot; class=&quot;ref-link&quot;&gt;dictionary&lt;/a&gt; with unique elements from the &lt;a href=&quot;/ref/glossary/sequence/&quot; class=&quot;ref-link&quot;&gt;sequence&lt;/a&gt; as keys and their frequencies (counts) as values.  Within the &lt;a href=&quot;/ref/glossary/loop/&quot; class=&quot;ref-link&quot;&gt;loop&lt;/a&gt; over &lt;code&gt;seq&lt;/code&gt;, &lt;code&gt;hist[i] = hist.get(i, 0) + 1&lt;/code&gt; says, “for each element of the sequence, increment its corresponding value in &lt;code&gt;hist&lt;/code&gt; by 1.”&lt;/p&gt;
&lt;p&gt;In fact, this is precisely what is done by the &lt;code&gt;collections.Counter&lt;/code&gt; &lt;a href=&quot;/ref/glossary/class/&quot; class=&quot;ref-link&quot;&gt;class&lt;/a&gt; from Python’s &lt;a href=&quot;/ref/best-practices/stdlib/&quot; class=&quot;ref-link&quot;&gt;standard library&lt;/a&gt;, which &lt;a href=&quot;https://github.com/python/cpython/blob/7f1bcda9bc3c04100cb047373732db0eba00e581/Lib/collections/__init__.py#L466&quot;&gt;subclasses&lt;/a&gt; a Python dictionary and overrides its &lt;code&gt;.update()&lt;/code&gt; &lt;a href=&quot;/ref/glossary/method/&quot; class=&quot;ref-link&quot;&gt;method&lt;/a&gt;:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;collections&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;Counter&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;recounted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&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;recounted&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Counter({1: 3, 7: 2, 0: 1, 2: 1, 3: 1, 23: 1})&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.8f1dcd28e216.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 confirm that your handmade &lt;a href=&quot;/ref/glossary/function/&quot; class=&quot;ref-link&quot;&gt;function&lt;/a&gt; does virtually the same thing as &lt;code&gt;collections.Counter&lt;/code&gt; by testing for equality between the two:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;recounted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;items&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;counted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;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.8f1dcd28e216.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 class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Technical Detail&lt;/strong&gt;: The &lt;a href=&quot;/ref/glossary/mapping/&quot; class=&quot;ref-link&quot;&gt;mapping&lt;/a&gt; from &lt;code&gt;count_elements()&lt;/code&gt; above defaults to a more highly optimized &lt;a href=&quot;https://github.com/python/cpython/blob/a5c42284e69fb309bdd17ee8c1c120d1be383012/Modules/_collectionsmodule.c#L2250&quot;&gt;C function&lt;/a&gt; if it is available.  Within the Python function &lt;code&gt;count_elements()&lt;/code&gt;, one micro-optimization you could make is to declare &lt;code&gt;get = hist.get&lt;/code&gt; before the &lt;code&gt;for&lt;/code&gt; loop.  This would bind a method to a &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variable&lt;/a&gt; for faster calls within the loop.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;It can be helpful to build simplified functions from scratch as a first step to understanding more complex ones. Let’s further reinvent the wheel a bit with an &lt;a href=&quot;/ref/glossary/ascii/&quot; class=&quot;ref-link&quot;&gt;ASCII&lt;/a&gt; histogram that takes advantage of Python’s &lt;a href=&quot;https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting&quot;&gt;output formatting&lt;/a&gt;:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ascii_histogram&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;A horizontal frequency-table/histogram plot.&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;counted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count_elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{0:5d}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{1}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;+&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&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.8f1dcd28e216.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 function creates a sorted frequency plot where counts are represented as tallies of plus (&lt;code&gt;+&lt;/code&gt;) symbols.  Calling &lt;a href=&quot;https://realpython.com/python-sort/&quot;&gt;&lt;code&gt;sorted()&lt;/code&gt;&lt;/a&gt; on a dictionary returns a sorted list of its keys, and then you access the corresponding value for each with &lt;code&gt;counted[k]&lt;/code&gt;.  To see this in action, you can create a slightly larger dataset with Python’s &lt;code&gt;random&lt;/code&gt; &lt;a href=&quot;/ref/glossary/module/&quot; class=&quot;ref-link&quot;&gt;module&lt;/a&gt;:&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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;c1&quot;&gt;# No NumPy ... yet&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;import&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;random&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;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seed&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;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&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;6&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;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Each number in `vals` will occur between 5 and 15 times.&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;freq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;randint&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;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vals&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;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;freq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vals&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;data&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;v&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;f&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;ascii_histogram&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    1 +++++++&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    3 ++++++++++++++&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    4 ++++++&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    6 +++++++++&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    8 ++++++&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    9 ++++++++++++&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;   10 ++++++++++++&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.8f1dcd28e216.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’re simulating plucking from &lt;code&gt;vals&lt;/code&gt; with frequencies given by &lt;code&gt;freq&lt;/code&gt; (a &lt;a href=&quot;https://realpython.com/introduction-to-python-generators/&quot;&gt;generator expression&lt;/a&gt;).  The resulting sample data repeats each value from &lt;code&gt;vals&lt;/code&gt; a certain number of times between 5 and 15.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-histograms/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-histograms/ »&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>How to Create a Django Project</title>
      <id>https://realpython.com/django-setup/</id>
      <link href="https://realpython.com/django-setup/"/>
      <updated>2026-10-17T14:00:00+00:00</updated>
      <summary>Learn how to create a Django project and app in clear, guided steps. Use it as a reference for any future Django project and tutorial you&#x27;ll work on.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Before you can start &lt;a href=&quot;https://realpython.com/get-started-with-django-1/&quot;&gt;building your Django web application&lt;/a&gt;, you need to set up your Django project. In this guide you’ll learn how to create a new Django project in four straightforward steps and only six commands:&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;Step&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;#step-1-prepare-your-environment&quot;&gt;1a&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Set up a virtual environment&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m venv .venv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;#step-1-prepare-your-environment&quot;&gt;1b&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Activate the virtual environment&lt;/td&gt;
&lt;td&gt;&lt;code&gt;source .venv/bin/activate&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;#step-2-install-django-and-pin-your-dependencies&quot;&gt;2a&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Install Django&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip install django&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;#step-2-install-django-and-pin-your-dependencies&quot;&gt;2b&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Pin your dependencies&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python -m pip freeze &amp;gt; requirements.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;#step-3-set-up-a-django-project&quot;&gt;3&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Set up a Django project&lt;/td&gt;
&lt;td&gt;&lt;code&gt;django-admin startproject &amp;lt;projectname&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;#step-4-start-a-django-app&quot;&gt;4&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Start a Django app&lt;/td&gt;
&lt;td&gt;&lt;code&gt;python manage.py startapp &amp;lt;appname&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;The tutorial focuses on the initial steps you’ll always need to start a new web application.&lt;/p&gt;
&lt;p&gt;Use this tutorial as your go-to reference until you’ve built so many projects that the necessary commands become second nature. Until then, follow the steps outlined below and in the &lt;a href=&quot;#command-reference-how-to-create-a-django-project&quot;&gt;command reference&lt;/a&gt;, or download the PDF cheatsheet as a printable reference:&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/django-project-cheatsheet/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-django-project-cheatsheet&quot; markdown&gt;Click here to download the Django Project cheat sheet&lt;/a&gt; that assembles all important commands and tips on one page that’s easy to print.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;There are also a few exercises throughout the tutorial to help reinforce what you’re learning, and you can test your knowledge in the associated quiz:&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.8f1dcd28e216.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 Create a Django Project” 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-12 col-sm-4 col-md-3 align-self-center&quot;&gt;

      &lt;a href=&quot;/quizzes/django-setup/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #abe0e6;&quot; alt=&quot;Django Setup Guide&quot; src=&quot;https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.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.8f1dcd28e216.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 position-relative&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/django-setup/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Create a Django Project&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Check your Django setup skills. Install safely and pin requirements, create a project and an app. Start building your first site.&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 Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/django-setup-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-django-setup-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to create a Django project.&lt;/p&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 creating your &lt;a href=&quot;https://www.djangoproject.com/&quot;&gt;Django&lt;/a&gt; project, make sure you have the right tools and knowledge in place. This tutorial assumes you’re comfortable working with the &lt;a href=&quot;/ref/glossary/console/&quot; class=&quot;ref-link&quot;&gt;command line&lt;/a&gt;, but you don’t need to be an expert. Here’s what you’ll need to get started:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;Python 3.12 or higher installed&lt;/a&gt; on your system&lt;/li&gt;
&lt;li&gt;Basic familiarity with &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environments&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Understanding of Python’s package manager, &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Access to a &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;command-line interface&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You don’t need any prior Django experience to complete this guide. However, to build functionality beyond the basic scaffolding, you’ll need to know &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;Python basics&lt;/a&gt; and at least some &lt;a href=&quot;https://realpython.com/learning-paths/django-web-development/&quot;&gt;Django&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;step-1-prepare-your-environment&quot;&gt;Step 1: Prepare Your Environment&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-prepare-your-environment&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you’re ready to start your new Django web application, create a new folder and navigate into it. In this folder, you’ll set up a new &lt;a href=&quot;/ref/glossary/virtual-environment/&quot; class=&quot;ref-link&quot;&gt;virtual environment&lt;/a&gt; using your &lt;a href=&quot;/ref/glossary/console/&quot; class=&quot;ref-link&quot;&gt;terminal&lt;/a&gt;:&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-bs-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 me-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.8f1dcd28e216.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-bs-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.8f1dcd28e216.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span class=&quot;icon baseline text-muted me-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.8f1dcd28e216.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;pscon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Windows PowerShell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; 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.8f1dcd28e216.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;PS&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;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;venv&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.8f1dcd28e216.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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;python3&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;/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.8f1dcd28e216.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;This command sets up a new virtual environment named &lt;code&gt;.venv&lt;/code&gt; in your current working directory. Once the process is complete, you also need to activate the virtual environment:&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-bs-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 me-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.8f1dcd28e216.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-bs-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.8f1dcd28e216.svg#v4--linux&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span class=&quot;icon baseline text-muted me-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.8f1dcd28e216.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;pscon&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Windows PowerShell&lt;/span&gt;
    
    &lt;div class=&quot;noselect&quot;&gt;
      
        &lt;span class=&quot;codeblock__output-toggle&quot; title=&quot;Toggle prompts and output&quot; 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.8f1dcd28e216.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;PS&amp;gt; &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;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;/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.8f1dcd28e216.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;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&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.8f1dcd28e216.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;source&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;.venv/bin/activate
&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.8f1dcd28e216.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;If the activation was successful, then you’ll see the name of your virtual environment, &lt;code&gt;(.venv)&lt;/code&gt;, at the beginning of your command prompt. This means that your environment setup is complete.&lt;/p&gt;
&lt;p&gt;You can learn more about how to &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;work with virtual environments in Python&lt;/a&gt;, and how to &lt;a href=&quot;https://realpython.com/learning-paths/perfect-your-python-development-setup/&quot;&gt;perfect your Python development setup&lt;/a&gt;, but for your Django setup, you have all you need. You can continue with installing the &lt;code&gt;django&lt;/code&gt; package.&lt;/p&gt;
&lt;h2 id=&quot;step-2-install-django-and-pin-your-dependencies&quot;&gt;Step 2: Install Django and Pin Your Dependencies&lt;a class=&quot;headerlink&quot; href=&quot;#step-2-install-django-and-pin-your-dependencies&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/django-setup/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/django-setup/ »&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: Python&#x27;s .__call__() Method: Creating Callable Instances</title>
      <id>https://realpython.com/quizzes/python-callable-instances/</id>
      <link href="https://realpython.com/quizzes/python-callable-instances/"/>
      <updated>2026-10-17T12:00:00+00:00</updated>
      <summary>Test your understanding of Python callables and see how the .__call__() method lets you call class instances just like regular functions.</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-callable-instances/&quot;&gt;Python&amp;rsquo;s &lt;code&gt;.__call__()&lt;/code&gt; Method: Creating Callable Instances&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit what makes an object callable, how to
check whether an object is callable, how &lt;code&gt;.__init__()&lt;/code&gt; and &lt;code&gt;.__call__()&lt;/code&gt; differ, and
how callable instances help you write stateful callables, cache results, design
convenient APIs, build class-based decorators, and implement the strategy pattern.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #315: Python Pitfalls: Common Mistakes and How to Avoid Them</title>
      <id>https://realpython.com/podcasts/rpp/315/</id>
      <link href="https://realpython.com/podcasts/rpp/315/"/>
      <updated>2026-10-16T12:00:00+00:00</updated>
      <summary>What are common mistakes that Python beginners make, and how do you avoid them? 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 are common mistakes that Python beginners make, and how do you avoid them? 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: Profiling in Python: How to Find Performance Bottlenecks</title>
      <id>https://realpython.com/quizzes/python-profiling/</id>
      <link href="https://realpython.com/quizzes/python-profiling/"/>
      <updated>2026-10-16T12:00:00+00:00</updated>
      <summary>Check how well you can find performance bottlenecks in Python with time, timeit, cProfile, Pyinstrument, and the Linux perf profiler.</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-profiling/&quot;&gt;Profiling in Python: How to Find Performance Bottlenecks&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit why you should profile before you optimize,
how to measure real and CPU time with &lt;code&gt;time&lt;/code&gt; and &lt;code&gt;timeit&lt;/code&gt;, and how deterministic profilers
like &lt;code&gt;cProfile&lt;/code&gt; compare to statistical ones like Pyinstrument.&lt;/p&gt;
&lt;p&gt;With these tools in your kit, you&amp;rsquo;ll be able to back up your optimization decisions with
real data instead of guesswork.&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: PyQt Layouts: Create Professional-Looking GUI Applications</title>
      <id>https://realpython.com/quizzes/python-pyqt-layout/</id>
      <link href="https://realpython.com/quizzes/python-pyqt-layout/"/>
      <updated>2026-10-15T12:00:00+00:00</updated>
      <summary>Test your PyQt layout skills with box, grid, form, stacked, and tab layouts so you can build polished GUI applications 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/python-pyqt-layout/&quot;&gt;PyQt Layouts: Create Professional-Looking GUI Applications&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to arrange widgets with PyQt&amp;rsquo;s
general-purpose layout managers, nest layouts, build multipage interfaces, and lay
out main windows and dialogs. You&amp;rsquo;ll also review how to manage the space between
widgets so your GUIs stay polished when users resize them.&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 and PyQt: Building a GUI Desktop Calculator</title>
      <id>https://realpython.com/quizzes/python-pyqt-gui-calculator/</id>
      <link href="https://realpython.com/quizzes/python-pyqt-gui-calculator/"/>
      <updated>2026-10-14T12:00:00+00:00</updated>
      <summary>Test your knowledge of building PyQt GUIs with widgets, layouts, and dialogs, connecting signals to slots, and structuring apps with MVC.</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-pyqt-gui-calculator/&quot;&gt;Python and PyQt: Building a GUI Desktop Calculator&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to create a PyQt app, arrange widgets with
layout managers, build main windows and dialogs, connect signals to slots, and structure a
GUI calculator with the Model-View-Controller pattern.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Use Python: Taking Your First Steps</title>
      <id>https://realpython.com/courses/python-first-steps/</id>
      <link href="https://realpython.com/courses/python-first-steps/"/>
      <updated>2026-10-13T14:00:00+00:00</updated>
      <summary>Take your first steps with Python. Install it, run your first program, and work with variables, data types, loops, functions, and errors.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re starting fresh with programming and wondering how to use Python, this video course will give you the foundation you need to get started with Python step by step. You&amp;rsquo;ll learn how to install Python, run your first program, and understand the language&amp;rsquo;s clear syntax.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll also explore variables, loops, functions, classes, and error handling while discovering tools, coding style, and libraries that help you write effective Python code from day one.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can &lt;strong&gt;install Python&lt;/strong&gt; on Windows, macOS, and Linux using binaries, package managers, or distributions like Anaconda.&lt;/li&gt;
&lt;li&gt;You can use the &lt;strong&gt;Python REPL&lt;/strong&gt; to experiment &lt;strong&gt;interactively&lt;/strong&gt; before writing full scripts, modules, and projects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built-in data types&lt;/strong&gt; like strings, lists, dictionaries, and sets provide powerful ways to structure information.&lt;/li&gt;
&lt;li&gt;You can &lt;strong&gt;handle errors&lt;/strong&gt; with syntax checks, exceptions, and debugging practices to keep your code running smoothly.&lt;/li&gt;
&lt;li&gt;Tools like &lt;strong&gt;editors&lt;/strong&gt;, &lt;strong&gt;integrated development environments (IDEs)&lt;/strong&gt;, and &lt;strong&gt;AI assistants&lt;/strong&gt; can boost your productivity when writing Python code.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;rsquo;ll take your first steps with clear examples so you can start coding in Python confidently and build on solid ground.&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 len() Function</title>
      <id>https://realpython.com/quizzes/pythons-len-function/</id>
      <link href="https://realpython.com/quizzes/pythons-len-function/"/>
      <updated>2026-10-13T12:00:00+00:00</updated>
      <summary>Test your understanding of Python&#x27;s len() function, from built-in containers to NumPy arrays, DataFrames, and your own classes.</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/pythons-len-function/&quot;&gt;Python&amp;rsquo;s len() Function&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit which objects &lt;code&gt;len()&lt;/code&gt; accepts, how it behaves
with NumPy arrays and pandas DataFrames, and how to support it in your own classes.&lt;/p&gt;
&lt;p&gt;Along the way, you&amp;rsquo;ll see why one small function can work on everything from built-in
containers to the classes you write.&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: Docling vs LlamaParse: How to Extract PDF Tables in Python</title>
      <id>https://realpython.com/quizzes/extract-table-from-pdf-python/</id>
      <link href="https://realpython.com/quizzes/extract-table-from-pdf-python/"/>
      <updated>2026-10-12T12:00:00+00:00</updated>
      <summary>Test your understanding of extracting PDF tables in Python with Docling and LlamaParse, and of when to parse locally instead of in the cloud.</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/extract-table-from-pdf-python/&quot;&gt;Docling vs LlamaParse: How to Extract PDF Tables in Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit why tables are hard to pull out of a PDF, how a local library and a cloud API divide up the work, and what each one hands back for tables, charts, and schema-driven fields.&lt;/p&gt;
&lt;p&gt;Along the way, you&amp;rsquo;ll think about data custody, model downloads, and where your compute actually happens.&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: Continuous Integration With Python: An Introduction</title>
      <id>https://realpython.com/quizzes/python-continuous-integration/</id>
      <link href="https://realpython.com/quizzes/python-continuous-integration/"/>
      <updated>2026-10-11T12:00:00+00:00</updated>
      <summary>Test your understanding of continuous integration in Python, from automated builds and unit tests to staging environments and deployable artifacts.</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-continuous-integration/&quot;&gt;Continuous Integration With Python: An Introduction&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit why teams integrate small changes often,
what it means to break the build, and how linting, unit tests, containers, and
deployable artifacts fit together in a continuous integration pipeline.&lt;/p&gt;
&lt;p&gt;These are the practices that let a team ship dozens of changes a day without anyone
waiting on someone else&amp;rsquo;s broken code.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: How to Get a List of All Files in a Directory With Python</title>
      <id>https://realpython.com/quizzes/get-all-files-in-directory-python/</id>
      <link href="https://realpython.com/quizzes/get-all-files-in-directory-python/"/>
      <updated>2026-10-10T12:00:00+00:00</updated>
      <summary>Revisit how to list files and folders in Python with pathlib. Check your grasp of .iterdir(), glob patterns, .rglob(), and skipping junk directories.</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/get-all-files-in-directory-python/&quot;&gt;How to Get a List of All Files in a Directory With Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how &lt;code&gt;.iterdir()&lt;/code&gt; hands you the contents of a single directory, how glob patterns let &lt;code&gt;.glob()&lt;/code&gt; and &lt;code&gt;.rglob()&lt;/code&gt; filter results by name, and how &lt;code&gt;.rglob()&lt;/code&gt; walks an entire directory tree.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll also check your understanding of filtering on attributes with comprehensions and &lt;code&gt;filter()&lt;/code&gt;, and of skipping junk directories instead of listing every file inside them.&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 #314: Codemoo: Demonstrating How Coding Agents Work</title>
      <id>https://realpython.com/podcasts/rpp/314/</id>
      <link href="https://realpython.com/podcasts/rpp/314/"/>
      <updated>2026-10-09T12:00:00+00:00</updated>
      <summary>How do you assemble the core pieces of a coding agent? How are developers defining projects through conversation and introspection? This week on the show, Geir Arne Hjelle returns to talk about his recent project to demonstrate how coding agents work under the hood.</summary>
      <content type="html">
        &lt;p&gt;How do you assemble the core pieces of a coding agent? How are developers defining projects through conversation and introspection? This week on the show, Geir Arne Hjelle returns to talk about his recent project to demonstrate how coding agents work under the hood.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Exploring the MVC Pattern in Python</title>
      <id>https://realpython.com/courses/exploring-mvc-pattern-python/</id>
      <link href="https://realpython.com/courses/exploring-mvc-pattern-python/"/>
      <updated>2026-10-06T14:00:00+00:00</updated>
      <summary>Learn how the Model-View-Controller pattern organizes Python web apps, then build a small Flask app using models, views, and controllers.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re curious about web development, then you&amp;rsquo;ve likely encountered the abbreviation &lt;strong&gt;MVC&lt;/strong&gt;, which stands for &lt;a href=&quot;https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller&quot;&gt;Model-View-Controller&lt;/a&gt;. You may know that it&amp;rsquo;s a common design pattern that&amp;rsquo;s fundamental to many Python web frameworks and even desktop applications.&lt;/p&gt;
&lt;p&gt;But what exactly does it mean? If you&amp;rsquo;ve had a hard time wrapping your head around the concept, then this video course is for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn what &lt;strong&gt;models&lt;/strong&gt;, &lt;strong&gt;views&lt;/strong&gt;, and &lt;strong&gt;controllers&lt;/strong&gt; are &lt;strong&gt;conceptually&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Follow a &lt;strong&gt;user&amp;rsquo;s request&lt;/strong&gt; through an MVC application from end to end&lt;/li&gt;
&lt;li&gt;Tie your conceptual understanding back to &lt;strong&gt;concrete web development examples&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build a small &lt;strong&gt;Flask&lt;/strong&gt; app that puts the MVC pattern into practice&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #313: Python 3.15: Exploring the New Features</title>
      <id>https://realpython.com/podcasts/rpp/313/</id>
      <link href="https://realpython.com/podcasts/rpp/313/"/>
      <updated>2026-10-02T12:00:00+00:00</updated>
      <summary>Python 3.15 is (almost*) here! Christopher Trudeau and Bartosz Zaczyński return to discuss the new version. Bartosz coordinated the series of preview articles with members of the Real Python team and wrote the showcase tutorial, &quot;Python 3.15: Cool New Features for You to Try.&quot; Christopher&#x27;s video course &quot;What&#x27;s New in Python 3.15&quot; covers the topics from the article and shows the new features in action.</summary>
      <content type="html">
        &lt;p&gt;Python 3.15 is (almost*) here! Christopher Trudeau and Bartosz Zaczyński return to discuss the new version. Bartosz coordinated the series of preview articles with members of the Real Python team and wrote the showcase tutorial, &quot;Python 3.15: Cool New Features for You to Try.&quot; Christopher&#x27;s video course &quot;What&#x27;s New in Python 3.15&quot; covers the topics from the article and shows the new features in action.&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>Community Videos</title>
      <id>https://realpython.com/courses/community-videos/</id>
      <link href="https://realpython.com/courses/community-videos/"/>
      <updated>2026-09-30T14:00:00+00:00</updated>
      <summary>Watch Real Python&#x27;s YouTube videos right here on the site, with the resources mentioned in each video and a full transcript.</summary>
      <content type="html">
        &lt;p&gt;This collection gathers the videos that the Real Python team published on the &lt;a href=&quot;https://www.youtube.com/@realpython&quot;&gt;Real Python YouTube channel&lt;/a&gt;, so you can watch them right here on Real Python.&lt;/p&gt;
&lt;p&gt;Each lesson contains the full video, the resources mentioned in it, and a transcript. The newest video is always at the top, and new videos are added as they&amp;rsquo;re released.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>What&#x27;s New in Python 3.15</title>
      <id>https://realpython.com/courses/whats-new-in-python-315/</id>
      <link href="https://realpython.com/courses/whats-new-in-python-315/"/>
      <updated>2026-09-29T14:00:00+00:00</updated>
      <summary>Explore the new features in Python 3.15, including lazy imports, frozendict, sentinel values, a sampling profiler, and a faster JIT.</summary>
      <content type="html">
        &lt;p&gt;Python 3.15 is here! After a last-minute third release candidate, the &lt;a href=&quot;https://www.python.org/downloads/release/python-3150/&quot;&gt;final release&lt;/a&gt; came out on October 9, 2026, so you can install it today and start using the new features in your own code. This is a good time to see what the new version has in store for you.&lt;/p&gt;
&lt;p&gt;This release trims the time you spend waiting. Imports can wait until you need them, the JIT compiler got faster, and a new profiler shows you where the remaining slow parts hide. There&amp;rsquo;s also plenty in it for everyday code, including two new built-in types.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll explore features like:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lazy imports&lt;/strong&gt; with the new &lt;code&gt;lazy&lt;/code&gt; keyword&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;frozendict&lt;/code&gt;&lt;/strong&gt;, an immutable mapping in the built-ins&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;sentinel&lt;/code&gt;&lt;/strong&gt;, a clean way to say &amp;ldquo;no value given&amp;rdquo;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A sampling profiler&lt;/strong&gt; that you can point at a running process&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;UTF-8&lt;/strong&gt; as the default encoding everywhere&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;An upgraded JIT compiler&lt;/strong&gt; with measurable speedups&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #312: Navigating AI in Open Source: Insights From Wagtail</title>
      <id>https://realpython.com/podcasts/rpp/312/</id>
      <link href="https://realpython.com/podcasts/rpp/312/"/>
      <updated>2026-09-25T12:00:00+00:00</updated>
      <summary>How should you manage AI contributions to an open-source project? How do you measure the impact of using AI tools for development, and what generative features do end users want from a content management system? This week on the show, we speak with Thibaud Colas and Meagen Voss from Wagtail about the complex considerations software organizations are currently facing.</summary>
      <content type="html">
        &lt;p&gt;How should you manage AI contributions to an open-source project? How do you measure the impact of using AI tools for development, and what generative features do end users want from a content management system? This week on the show, we speak with Thibaud Colas and Meagen Voss from Wagtail about the complex considerations software organizations are currently facing.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Using the Claude API in Python</title>
      <id>https://realpython.com/courses/using-claude-api-python/</id>
      <link href="https://realpython.com/courses/using-claude-api-python/"/>
      <updated>2026-09-22T14: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 output.</summary>
      <content type="html">
        &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&amp;rsquo;ll have a working response in under a minute.&lt;/p&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&amp;rsquo;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 this video course, you&amp;rsquo;ll install the &lt;code&gt;anthropic&lt;/code&gt; SDK, call Claude from Python, shape Claude&amp;rsquo;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 &lt;a href=&quot;https://realpython.com/python-pydantic/&quot;&gt;Pydantic&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Claude&amp;rsquo;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;p&gt;Each lesson 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;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>Automating EDA With fg-data-profiling</title>
      <id>https://realpython.com/courses/automating-eda-with-fg-data-profiling/</id>
      <link href="https://realpython.com/courses/automating-eda-with-fg-data-profiling/"/>
      <updated>2026-09-15T14:00:00+00:00</updated>
      <summary>Automate exploratory data analysis by transforming DataFrames into interactive reports with one command from fg-data-profiling.</summary>
      <content type="html">
        &lt;p&gt;The &lt;code&gt;fg-data-profiling&lt;/code&gt; package generates an exploratory data analysis (EDA) report with a few lines of code. The report provides a dataset and column-level analysis, including plots and summary statistics, to help you quickly understand your dataset. These reports can be exported to HTML or JSON so you can share them with other stakeholders.&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;&lt;code&gt;fg-data-profiling&lt;/code&gt; generates interactive reports&lt;/strong&gt; containing EDA results, including summary statistics, visualizations, correlation matrices, and data quality warnings from DataFrames.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ProfileReport&lt;/code&gt; creates a profile&lt;/strong&gt; you can save with &lt;code&gt;.to_file()&lt;/code&gt; for HTML or JSON export, or display inline with &lt;code&gt;.to_notebook_iframe()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Setting &lt;code&gt;tsmode=True&lt;/code&gt; and specifying a date column with &lt;code&gt;sortby&lt;/code&gt; &lt;strong&gt;enables time series analysis&lt;/strong&gt;, including stationarity tests and seasonality detection.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The &lt;code&gt;.compare()&lt;/code&gt; method generates side-by-side reports&lt;/strong&gt; highlighting distribution shifts and statistical differences between datasets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this course, you&amp;rsquo;ll benefit from having knowledge of &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt;.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #311: Django Developers Survey Results &amp; Reproducible Python Builds</title>
      <id>https://realpython.com/podcasts/rpp/311/</id>
      <link href="https://realpython.com/podcasts/rpp/311/"/>
      <updated>2026-09-11T12:00:00+00:00</updated>
      <summary>What are the latest trends uncovered in the 2026 Django Developers Survey? How are Django users employing LLMs in their development process? 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 are the latest trends uncovered in the 2026 Django Developers Survey? How are Django users employing LLMs in their development process? 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>Python Timer Functions</title>
      <id>https://realpython.com/courses/python-timer-functions/</id>
      <link href="https://realpython.com/courses/python-timer-functions/"/>
      <updated>2026-09-08T14:00:00+00:00</updated>
      <summary>Learn how to time your Python code with the time module, then build a reusable Timer class that works as a context manager.</summary>
      <content type="html">
        &lt;p&gt;A timer is a powerful tool for monitoring the performance of your Python code. By using the &lt;code&gt;time.perf_counter()&lt;/code&gt; function, you can measure execution time with exceptional precision, making it ideal for benchmarking. Using a timer involves recording timestamps before and after a specific code block and calculating the time difference to determine how long your code took to run.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll start with the timer functions in Python&amp;rsquo;s &lt;code&gt;time&lt;/code&gt; module and then abstract them into a reusable &lt;code&gt;Timer&lt;/code&gt; class. You&amp;rsquo;ll extend that class to track multiple timers, convert it to a data class for convenience, and finally turn it into a context manager so you can time a block of code using a single &lt;code&gt;with&lt;/code&gt; statement.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;time.perf_counter()&lt;/code&gt;&lt;/strong&gt; is the best choice for accurate timing in Python due to its high resolution.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;process_time()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;time()&lt;/code&gt;&lt;/strong&gt; measure different things, so picking the wrong one can skew your results.&lt;/li&gt;
&lt;li&gt;You can create a &lt;strong&gt;custom timer class&lt;/strong&gt; to encapsulate timing logic and reuse it across multiple parts of your program.&lt;/li&gt;
&lt;li&gt;Turning your timer into a &lt;strong&gt;data class&lt;/strong&gt; cuts down on boilerplate and makes it easier to configure.&lt;/li&gt;
&lt;li&gt;You can leverage &lt;strong&gt;context managers&lt;/strong&gt; to neatly measure execution time in specific code blocks, improving both resource management and code clarity.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you&amp;rsquo;ll gain deeper insights into how &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;classes&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-data-classes/&quot;&gt;data classes&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-with-statement/&quot;&gt;context managers&lt;/a&gt; work in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #310: Performance Engineering: Profiling and Making Apps Fast by Default</title>
      <id>https://realpython.com/podcasts/rpp/310/</id>
      <link href="https://realpython.com/podcasts/rpp/310/"/>
      <updated>2026-09-04T12:00:00+00:00</updated>
      <summary>How do you plan for the performance of your Python applications? What does a performance budget entail, and where should you spend your resources? This week on the show, we speak with Den Odell about his new book &quot;Fast by Default: Practical Performance Engineering.&quot;</summary>
      <content type="html">
        &lt;p&gt;How do you plan for the performance of your Python applications? What does a performance budget entail, and where should you spend your resources? This week on the show, we speak with Den Odell about his new book &quot;Fast by Default: Practical Performance Engineering.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Get Started With Ollama</title>
      <id>https://realpython.com/courses/get-started-with-ollama/</id>
      <link href="https://realpython.com/courses/get-started-with-ollama/"/>
      <updated>2026-09-01T14:00:00+00:00</updated>
      <summary>Learn how to install Ollama, pull local models, and connect them to your Python code using the chat and text generation interfaces.</summary>
      <content type="html">
        &lt;p&gt;Integrating local large language models (LLMs) into your Python projects with Ollama is a great way to improve privacy, reduce costs, and build offline-capable AI-powered apps.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ollama&lt;/strong&gt; is an open-source platform that makes it straightforward to run modern LLMs locally on your machine. Once you&amp;rsquo;ve set up Ollama and pulled the models you want to use, you can connect to them from Python using the &lt;code&gt;ollama&lt;/code&gt; library.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll integrate local LLMs into your Python projects using the Ollama platform and its Python SDK.&lt;/p&gt;
&lt;p&gt;First, you&amp;rsquo;ll set up Ollama and pull a couple of LLMs. Then, you&amp;rsquo;ll learn how to use chat and text generation from your Python code. These skills will enable you to build AI-powered apps that run locally, ensuring better privacy and reducing costs.&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 #309: Exploring Complex Systems &amp; Maintainable Data Science Pipelines</title>
      <id>https://realpython.com/podcasts/rpp/309/</id>
      <link href="https://realpython.com/podcasts/rpp/309/"/>
      <updated>2026-08-28T12:00:00+00:00</updated>
      <summary>What are the key characteristics of complex systems, and what are practical patterns for tackling complex coding problems? 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 are the key characteristics of complex systems, and what are practical patterns for tackling complex coding problems? 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>The Python print() Function: Go Beyond the Basics</title>
      <id>https://realpython.com/courses/python-print/</id>
      <link href="https://realpython.com/courses/python-print/"/>
      <updated>2026-08-25T14:00:00+00:00</updated>
      <summary>Learn about Python&#x27;s print() function, discover its lesser-known features, avoid common mistakes, and know when to use a better alternative.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re like most Python users, including us, then you probably started your Python journey by learning about &lt;strong&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/strong&gt;. It helped you write your very own &lt;code&gt;Hello World&lt;/code&gt; one-liner. You can use it to display formatted messages onto the screen and perhaps find some bugs. But if you think that&amp;rsquo;s all there is to know about Python&amp;rsquo;s &lt;code&gt;print()&lt;/code&gt;, then you&amp;rsquo;re missing out on a lot!&lt;/p&gt;
&lt;p&gt;Keep reading to take full advantage of this underappreciated little function. This course will get you up to speed with using Python &lt;code&gt;print()&lt;/code&gt; effectively. Prepare for a deep dive as you go through the sections. You may be surprised how much &lt;code&gt;print()&lt;/code&gt; has to offer!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this course, you&amp;rsquo;ll know how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Avoid common mistakes with Python&amp;rsquo;s &lt;code&gt;print()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Deal with newlines, character encodings, and buffering&lt;/li&gt;
&lt;li&gt;Write text to files&lt;/li&gt;
&lt;li&gt;Mock &lt;code&gt;print()&lt;/code&gt; in unit tests&lt;/li&gt;
&lt;li&gt;Build advanced user interfaces in the terminal&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;print()&lt;/code&gt; was a major addition to Python 3, in which it replaced the old &lt;code&gt;print&lt;/code&gt; statement available in Python 2.&lt;/p&gt;
&lt;p&gt;There were a number of good reasons for that, as you&amp;rsquo;ll see shortly. Although this tutorial focuses on Python 3, it does show the old way of printing in Python for reference.&lt;/p&gt;
&lt;/div&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 #308: Navigating Silent Failures in AI: Strategies for Effective Oversight</title>
      <id>https://realpython.com/podcasts/rpp/308/</id>
      <link href="https://realpython.com/podcasts/rpp/308/"/>
      <updated>2026-08-21T12:00:00+00:00</updated>
      <summary>Why do AI systems silently fail? How can you set up a system that produces results while also reviewing and validating the work? This week on the show, Calvin Hendryx-Parker returns to discuss his recent talk &quot;Orchestrate Agentic AI: Context, Checklists, and No-Miss Reviews.&quot;</summary>
      <content type="html">
        &lt;p&gt;Why do AI systems silently fail? How can you set up a system that produces results while also reviewing and validating the work? This week on the show, Calvin Hendryx-Parker returns to discuss his recent talk &quot;Orchestrate Agentic AI: Context, Checklists, and No-Miss Reviews.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Working With Python&#x27;s deque</title>
      <id>https://realpython.com/courses/working-with-pythons-deque/</id>
      <link href="https://realpython.com/courses/working-with-pythons-deque/"/>
      <updated>2026-08-18T14:00:00+00:00</updated>
      <summary>Learn how to use Python&#x27;s deque to efficiently append and pop items from both ends, build queues and stacks, and set maxlen for bounded history.</summary>
      <content type="html">
        &lt;p&gt;You can use Python&amp;rsquo;s &lt;code&gt;deque&lt;/code&gt; for efficient appends and pops at both ends of a sequence-like data type. These capabilities are critical when you need to implement queue and stack data structures that operate efficiently even under heavy workloads.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll learn how &lt;code&gt;deque&lt;/code&gt; works, when to use it over a &lt;code&gt;list&lt;/code&gt;, and how to apply it in real code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;deque&lt;/code&gt; internally uses a &lt;strong&gt;doubly &lt;a href=&quot;/ref/computer-science-glossary/linked-list/&quot; class=&quot;ref-link&quot;&gt;linked list&lt;/a&gt;&lt;/strong&gt;, so end operations are &lt;em&gt;O(1)&lt;/em&gt; while random indexing is &lt;em&gt;O(n)&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;You can build a &lt;strong&gt;FIFO queue&lt;/strong&gt; with &lt;strong&gt;&lt;code&gt;.append()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;.popleft()&lt;/code&gt;&lt;/strong&gt;, and a &lt;strong&gt;LIFO stack&lt;/strong&gt; with &lt;strong&gt;&lt;code&gt;.append()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;.pop()&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;deque&lt;/code&gt; supports &lt;strong&gt;indexing&lt;/strong&gt; but doesn&amp;rsquo;t support &lt;strong&gt;slicing&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Passing a value to &lt;strong&gt;&lt;code&gt;maxlen&lt;/code&gt;&lt;/strong&gt; creates a bounded deque that &lt;strong&gt;drops items&lt;/strong&gt; from the opposite end when full.&lt;/li&gt;
&lt;li&gt;In CPython, &lt;strong&gt;&lt;code&gt;.append()&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;.appendleft()&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;.pop()&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;.popleft()&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;code&gt;len()&lt;/code&gt;&lt;/strong&gt; are &lt;strong&gt;thread-safe&lt;/strong&gt; for multithreaded use.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Up next, you&amp;rsquo;ll get started with &lt;code&gt;deque&lt;/code&gt;, benchmark it against &lt;code&gt;list&lt;/code&gt;, and explore how it shines in real-world use cases, such as queues, stacks, history buffers, and thread-safe producer-consumer setups.&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 #307: Improving NumPy Performance on Free-Threaded Python</title>
      <id>https://realpython.com/podcasts/rpp/307/</id>
      <link href="https://realpython.com/podcasts/rpp/307/"/>
      <updated>2026-08-14T12:00:00+00:00</updated>
      <summary>What bottlenecks were preventing NumPy from scaling on free-threaded Python? 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 bottlenecks were preventing NumPy from scaling on free-threaded Python? 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>The Real Python Podcast – Episode #306: Programmatically Developing LLM Prompts With DSPy</title>
      <id>https://realpython.com/podcasts/rpp/306/</id>
      <link href="https://realpython.com/podcasts/rpp/306/"/>
      <updated>2026-08-07T12:00:00+00:00</updated>
      <summary>How can you move from manually writing prompts for an LLM application toward defining them programmatically? This week on the show, Brett Kennedy returns to discuss his new book &quot;Building LLM Applications with DSPy.&quot;</summary>
      <content type="html">
        &lt;p&gt;How can you move from manually writing prompts for an LLM application toward defining them programmatically? This week on the show, Brett Kennedy returns to discuss his new book &quot;Building LLM Applications with DSPy.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Learning Path: FastAPI: Python API Development With Light Speed</title>
      <id>https://realpython.com/learning-paths/fastapi/</id>
      <link href="https://realpython.com/learning-paths/fastapi/"/>
      <updated>2026-07-22T12:00:00+00:00</updated>
      <summary>Learn FastAPI from the ground up. Build REST APIs, serve web pages with Jinja2 templates, and create a complete URL shortener project in Python.</summary>
      <content type="html">
        &lt;p&gt;Learn FastAPI from the ground up. Build REST APIs, serve web pages with Jinja2 templates, and create a complete URL shortener project in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>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>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>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. Choose an editor-based assistant like Cursor or a terminal-based one like Claude Code, then make it part of your daily workflow.</summary>
      <content type="html">
        &lt;p&gt;Use AI coding assistants to write, review, and debug Python code faster. Choose an editor-based assistant like Cursor or a terminal-based one like Claude Code, then make it part of your daily workflow.&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: Ace Your Python Coding Interview</title>
      <id>https://realpython.com/learning-paths/python-interview/</id>
      <link href="https://realpython.com/learning-paths/python-interview/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Prepare for Python coding interviews with practice problems, tips for standing out, and resources from top PyCon talks and Python books.</summary>
      <content type="html">
        &lt;p&gt;Prepare for Python coding interviews with practice problems, tips for standing out, and resources from top PyCon talks and Python books.&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: Python Data Structures</title>
      <id>https://realpython.com/learning-paths/basic-python-data-structures/</id>
      <link href="https://realpython.com/learning-paths/basic-python-data-structures/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn Python&#x27;s built-in data structures: strings, lists, tuples, dictionaries, sets, and bytes, plus sorting, copying, and comprehensions.</summary>
      <content type="html">
        &lt;p&gt;Learn Python&#x27;s built-in data structures: strings, lists, tuples, dictionaries, sets, and bytes, plus sorting, copying, and comprehensions.&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: Testing and Continuous Integration</title>
      <id>https://realpython.com/learning-paths/test-your-python-apps/</id>
      <link href="https://realpython.com/learning-paths/test-your-python-apps/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn how to test Python code with unittest, doctest, pytest, and mock objects. Set up continuous integration with GitHub Actions and Docker.</summary>
      <content type="html">
        &lt;p&gt;Learn how to test Python code with unittest, doctest, pytest, and mock objects. Set up continuous integration with GitHub Actions and Docker.&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: Exceptions, Logging, and Debugging</title>
      <id>https://realpython.com/learning-paths/exception-handling-logging-debugging/</id>
      <link href="https://realpython.com/learning-paths/exception-handling-logging-debugging/"/>
      <updated>2024-11-14T12:00:00+00:00</updated>
      <summary>Learn Python exception handling, logging, and debugging. Work with raise, built-in exceptions, the logging module, and pdb to write reliable code.</summary>
      <content type="html">
        &lt;p&gt;Learn Python exception handling, logging, and debugging. Work with raise, built-in exceptions, the logging module, and pdb to write reliable code.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>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>
  

</feed>
