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

  
    <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>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>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 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>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>How to Run Your Python Scripts and Code</title>
      <id>https://realpython.com/run-python-scripts/</id>
      <link href="https://realpython.com/run-python-scripts/"/>
      <updated>2026-10-16T14:00:00+00:00</updated>
      <summary>Learn how to run Python scripts from the command line, REPL, IDEs, and file managers on Windows, Linux, and macOS. Master all execution approaches.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Running Python scripts is essential for executing your code. You can run Python scripts from the command line using &lt;code&gt;python script.py&lt;/code&gt;, directly by making files executable with &lt;a href=&quot;/ref/glossary/shebang/&quot; class=&quot;ref-link&quot;&gt;shebangs&lt;/a&gt; on Unix systems, or through IDEs and code editors. Python also supports interactive execution through the standard &lt;a href=&quot;/ref/glossary/repl/&quot; class=&quot;ref-link&quot;&gt;REPL&lt;/a&gt; for testing code snippets.&lt;/p&gt;
&lt;p&gt;This tutorial covers the most common practical approaches for running Python scripts across Windows, Linux, and macOS.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;python&lt;/code&gt;&lt;/strong&gt; command followed by a &lt;strong&gt;script filename&lt;/strong&gt; executes the code from the &lt;strong&gt;command line&lt;/strong&gt; on all operating systems.&lt;/li&gt;
&lt;li&gt;Script mode runs code from &lt;strong&gt;files sequentially&lt;/strong&gt;, while interactive mode uses the &lt;strong&gt;REPL&lt;/strong&gt; for execution and testing with immediate feedback.&lt;/li&gt;
&lt;li&gt;Unix systems require &lt;strong&gt;executable permissions&lt;/strong&gt; and a &lt;strong&gt;shebang line&lt;/strong&gt; like &lt;code&gt;#!/usr/bin/env python3&lt;/code&gt; to run scripts directly as programs.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;python&lt;/code&gt; command’s &lt;code&gt;-m&lt;/code&gt; option runs &lt;strong&gt;Python modules&lt;/strong&gt; by searching &lt;code&gt;sys.path&lt;/code&gt; rather than requiring file paths.&lt;/li&gt;
&lt;li&gt;IDEs like &lt;a href=&quot;/ref/code-editors-ides/pycharm/&quot; class=&quot;ref-link&quot;&gt;PyCharm&lt;/a&gt; and code editors like &lt;a href=&quot;/ref/code-editors-ides/visual-studio-code/&quot; class=&quot;ref-link&quot;&gt;Visual Studio Code&lt;/a&gt; provide built-in options to &lt;strong&gt;run scripts&lt;/strong&gt; from the environment interface.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this tutorial, you should know the basics of working with your operating system’s &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt; and file manager. It’d also be beneficial to be familiar with a Python-friendly &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;IDE or code editor&lt;/a&gt; and with the standard Python &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt; (Read-Eval-Print Loop).&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-tricks-sample/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-tricks-sample&quot; markdown&gt;Get a sample chapter from Python Tricks: The Book&lt;/a&gt; that shows you Python’s best practices with simple examples you can apply instantly to write more beautiful + Pythonic code.&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 Run Your Python Scripts” 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/run-python-scripts/&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: #e6c7ab;&quot; alt=&quot;How to Run Your Python Scripts&quot; src=&quot;https://files.realpython.com/media/How-to-Run-A-Python-Script_Watermarked.65fe32bf5487.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-Run-A-Python-Script_Watermarked.65fe32bf5487.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Run-A-Python-Script_Watermarked.65fe32bf5487.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Run-A-Python-Script_Watermarked.65fe32bf5487.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Run-A-Python-Script_Watermarked.65fe32bf5487.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/run-python-scripts/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;How to Run Your Python Scripts&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;One of the most important skills you need to build as a Python developer is to be able to run Python scripts and code. Test your understanding on how good you are with running your code.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;what-scripts-and-modules-are&quot;&gt;What Scripts and Modules Are&lt;a class=&quot;headerlink&quot; href=&quot;#what-scripts-and-modules-are&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In computing, the term &lt;strong&gt;script&lt;/strong&gt; refers to a text file containing a logical sequence of orders that you can run to accomplish a specific task. These orders are typically expressed in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Scripting_language&quot;&gt;scripting language&lt;/a&gt;, which is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Programming_language&quot;&gt;programming language&lt;/a&gt; that allows you to manipulate, customize, and automate tasks.&lt;/p&gt;
&lt;p&gt;Scripting languages are usually &lt;a href=&quot;https://en.wikipedia.org/wiki/Interpreter_(computing)&quot;&gt;interpreted&lt;/a&gt; at &lt;a href=&quot;https://en.wikipedia.org/wiki/Runtime_(program_lifecycle_phase)&quot;&gt;runtime&lt;/a&gt; rather than &lt;a href=&quot;https://en.wikipedia.org/wiki/Compiler&quot;&gt;compiled&lt;/a&gt;. So, scripts are typically run by an &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt;, which is responsible for executing each order in a sequence.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/ref/glossary/python/&quot; class=&quot;ref-link&quot;&gt;Python&lt;/a&gt; is an interpreted language. Because of that, Python programs are commonly called scripts. However, this terminology isn’t completely accurate because Python programs can be way more complex than a simple, sequential script.&lt;/p&gt;
&lt;p&gt;In general, a &lt;a href=&quot;/ref/glossary/text-file/&quot; class=&quot;ref-link&quot;&gt;file&lt;/a&gt; containing executable Python &lt;a href=&quot;/ref/glossary/source-code/&quot; class=&quot;ref-link&quot;&gt;code&lt;/a&gt; is called a script—or an &lt;strong&gt;entry-point script&lt;/strong&gt; in more complex applications—which is a common term for a top-level &lt;strong&gt;program&lt;/strong&gt;. On the other hand, a file containing Python code that’s designed to be &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;imported&lt;/a&gt; and used from another Python file is called a &lt;a href=&quot;/ref/glossary/module/&quot; class=&quot;ref-link&quot;&gt;&lt;strong&gt;module&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, the main difference between a &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;module&lt;/a&gt; and a script is that modules store &lt;strong&gt;importable code&lt;/strong&gt; while scripts hold &lt;strong&gt;executable code&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Importable code is code that defines something but doesn’t perform a specific action. Some examples include &lt;a href=&quot;/ref/glossary/function/&quot; class=&quot;ref-link&quot;&gt;function&lt;/a&gt; and &lt;a href=&quot;/ref/glossary/class/&quot; class=&quot;ref-link&quot;&gt;class&lt;/a&gt; definitions. In contrast, executable code is code that performs specific actions. Some examples include &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/#calling-functions-in-python&quot;&gt;function calls&lt;/a&gt;, &lt;a href=&quot;/ref/glossary/loop/&quot; class=&quot;ref-link&quot;&gt;loops&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditionals&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In the following sections, you’ll learn how to run Python scripts, programs, and code in general. To kick things off, you’ll start by learning how to run them from your operating system’s command line or terminal.&lt;/p&gt;
&lt;h2 id=&quot;how-to-run-python-scripts-from-the-command-line&quot;&gt;How to Run Python Scripts From the Command Line&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-run-python-scripts-from-the-command-line&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python programming, you’ll write programs in plain text files. By convention, files containing Python code use the &lt;code&gt;.py&lt;/code&gt; extension, and there’s no distinction between scripts or executable programs and modules. All of them will use the same extension.&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; On &lt;a href=&quot;https://realpython.com/python-coding-setup-windows/&quot;&gt;Windows&lt;/a&gt; systems, the extension can also be &lt;code&gt;.pyw&lt;/code&gt; for those applications that should use the &lt;code&gt;pythonw.exe&lt;/code&gt; launcher.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To create a Python script, you can use any Python-friendly &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;code editor or IDE&lt;/a&gt; (integrated development environment). To keep moving forward in this tutorial, you’ll need to create a basic script, so fire up your favorite text editor and create a new &lt;code&gt;hello.py&lt;/code&gt; file containing the following code:&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;hello.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;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;Hello, World!&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;This is the classic &lt;code&gt;&quot;Hello, World!&quot;&lt;/code&gt; program in Python. The executable code consists of a call to the built-in &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; function that displays the &lt;code&gt;&quot;Hello, World!&quot;&lt;/code&gt; message on your screen.&lt;/p&gt;
&lt;p&gt;With this small program in place, you’re ready to learn different ways to run it. You’ll start by running the program from your command line, which is arguably the most commonly used approach to running scripts.&lt;/p&gt;
&lt;h3 id=&quot;using-the-python-command&quot;&gt;Using the &lt;code&gt;python&lt;/code&gt; Command&lt;a class=&quot;headerlink&quot; href=&quot;#using-the-python-command&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To run Python scripts with the &lt;code&gt;python&lt;/code&gt; command, you need to open a command-line window and type in the word &lt;code&gt;python&lt;/code&gt; followed by the path to your target script:&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&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/run-python-scripts/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/run-python-scripts/ »&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 Exceptions: An Introduction</title>
      <id>https://realpython.com/python-exceptions/</id>
      <link href="https://realpython.com/python-exceptions/"/>
      <updated>2026-10-16T14:00:00+00:00</updated>
      <summary>Learn what Python exceptions are, how to raise them, how to handle them with try, except, else, and finally, and how to create custom ones.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python exceptions provide a mechanism for handling errors that occur during the execution of a program. Unlike syntax errors, which are detected by the parser, Python raises &lt;a href=&quot;/ref/glossary/exception/&quot; class=&quot;ref-link&quot;&gt;exceptions&lt;/a&gt; when an error occurs in syntactically correct code. Knowing how to raise, catch, and handle exceptions effectively helps to ensure your program behaves as expected, even when encountering errors.&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;Exceptions in Python occur when &lt;strong&gt;syntactically correct code&lt;/strong&gt; results in an &lt;strong&gt;error&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The &lt;code&gt;try&lt;/code&gt; … &lt;code&gt;except&lt;/code&gt; block&lt;/strong&gt; lets you execute code and handle exceptions that arise.&lt;/li&gt;
&lt;li&gt;You can use the &lt;code&gt;else&lt;/code&gt; and &lt;code&gt;finally&lt;/code&gt; &lt;strong&gt;keywords&lt;/strong&gt; for more refined &lt;strong&gt;exception handling&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;It’s &lt;strong&gt;bad practice&lt;/strong&gt; to &lt;strong&gt;catch all exceptions&lt;/strong&gt; at once using &lt;code&gt;except Exception&lt;/code&gt; or the bare &lt;code&gt;except&lt;/code&gt; clause.&lt;/li&gt;
&lt;li&gt;Combining &lt;code&gt;try&lt;/code&gt;, &lt;code&gt;except&lt;/code&gt;, and &lt;code&gt;pass&lt;/code&gt; allows your program to &lt;strong&gt;continue silently&lt;/strong&gt; without handling the exception.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, you’ll get to know Python exceptions and all relevant keywords for &lt;a href=&quot;/ref/best-practices/exception-handling/&quot; class=&quot;ref-link&quot;&gt;exception handling&lt;/a&gt; by walking through a practical example of handling a platform-related exception. Finally, you’ll also learn how to create your own custom Python exceptions.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-exceptions-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-exceptions-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how exceptions work 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 Exceptions: An Introduction” 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-exceptions/&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: #ffc873;&quot; alt=&quot;An Introduction to Python Exceptions&quot; src=&quot;https://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.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_Exceptions_Watermark.47f814fbeced.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.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-exceptions/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python Exceptions: An Introduction&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python exceptions. You&#x27;ll cover the difference between syntax errors and exceptions and learn how to raise exceptions, make assertions, and use the try and except block.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;understanding-exceptions-and-syntax-errors&quot;&gt;Understanding Exceptions and Syntax Errors&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-exceptions-and-syntax-errors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://realpython.com/invalid-syntax-python/&quot;&gt;Syntax errors&lt;/a&gt; occur when the parser detects an incorrect &lt;a href=&quot;/ref/glossary/statement/&quot; class=&quot;ref-link&quot;&gt;statement&lt;/a&gt;. Observe the following example:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pytb&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 Traceback&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;x&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print(0 / 0))&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&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;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;pm&quot;&gt;^&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;SyntaxError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;unmatched &#x27;)&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; aria-label=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.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 arrow indicates where the parser ran into the &lt;strong&gt;syntax error&lt;/strong&gt;. Additionally, the error message gives you a hint about what went wrong. In this example, there was one bracket too many. Remove it and run your code again:&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;print&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;o&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;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;, in &lt;span class=&quot;n&quot;&gt;&amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;w&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;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;pm&quot;&gt;~~^~~&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;ZeroDivisionError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;division by zero&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 time, you ran into an &lt;strong&gt;exception error&lt;/strong&gt;. This type of error occurs whenever syntactically correct Python code results in an error. The last line of the message indicates what type of exception error you ran into.&lt;/p&gt;
&lt;p&gt;Instead of just writing &lt;em&gt;exception error&lt;/em&gt;, Python details what &lt;em&gt;type&lt;/em&gt; of exception error it encountered. In this case, it was a &lt;a href=&quot;/ref/builtin-exceptions/zerodivisionerror/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;ZeroDivisionError&lt;/code&gt;&lt;/a&gt;. Python comes with &lt;a href=&quot;https://docs.python.org/3/library/exceptions.html&quot;&gt;various built-in exceptions&lt;/a&gt; as well as the possibility to create user-defined exceptions.&lt;/p&gt;
&lt;h2 id=&quot;raising-an-exception-in-python&quot;&gt;Raising an Exception in Python&lt;a class=&quot;headerlink&quot; href=&quot;#raising-an-exception-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are scenarios where you might want to stop your program by raising an exception if a condition occurs. You can do this with the &lt;a href=&quot;https://realpython.com/python-raise-exception/&quot;&gt;&lt;code&gt;raise&lt;/code&gt;&lt;/a&gt; keyword:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/raise.3931e8819e08.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/raise.3931e8819e08.png&quot; width=&quot;1394&quot; height=&quot;311&quot; srcset=&quot;/cdn-cgi/image/width=348,format=auto/https://files.realpython.com/media/raise.3931e8819e08.png 348w, /cdn-cgi/image/width=464,format=auto/https://files.realpython.com/media/raise.3931e8819e08.png 464w, /cdn-cgi/image/width=697,format=auto/https://files.realpython.com/media/raise.3931e8819e08.png 697w, /cdn-cgi/image/width=1394,format=auto/https://files.realpython.com/media/raise.3931e8819e08.png 1394w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Illustration of  raise statement usage&quot; data-asset=&quot;394&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;You can even complement the statement with a custom message. Assume that you’re writing a tiny toy program that expects only numbers up to &lt;code&gt;5&lt;/code&gt;. You can raise an error when an unwanted condition occurs:&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;low.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;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;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;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The number should not exceed 5. (&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;=}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/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;In this example, you raised an &lt;code&gt;Exception&lt;/code&gt; &lt;a href=&quot;/ref/glossary/object/&quot; class=&quot;ref-link&quot;&gt;object&lt;/a&gt; and passed it an informative custom message. You built the message using an &lt;a href=&quot;https://realpython.com/python-f-strings/&quot;&gt;f-string&lt;/a&gt; and a &lt;a href=&quot;https://realpython.com/python-f-strings/#self-documenting-expressions-for-debugging&quot;&gt;self-documenting expression&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you run &lt;code&gt;low.py&lt;/code&gt;, you’ll get the following output:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;pytb&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 Traceback&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;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;./low.py&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;, in &lt;span class=&quot;n&quot;&gt;&amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The number should not exceed 5. (&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;=}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;Exception&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;The number should not exceed 5. (number=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;The program comes to a halt and displays the exception to your &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;REPL&lt;/a&gt;, offering you helpful clues about what went wrong. Note that the final call to &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; never executed, because Python raised the exception before it got to that line of code.&lt;/p&gt;
&lt;p&gt;With the &lt;code&gt;raise&lt;/code&gt; keyword, you can raise any exception object in Python and stop your program when an unwanted condition occurs.&lt;/p&gt;
&lt;h2 id=&quot;debugging-during-development-with-assert&quot;&gt;Debugging During Development With &lt;code&gt;assert&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#debugging-during-development-with-assert&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before moving on to the most common way of working with exceptions in Python using &lt;a href=&quot;#handling-exceptions-with-the-try-and-except-block&quot;&gt;the &lt;code&gt;try&lt;/code&gt; … &lt;code&gt;except&lt;/code&gt; block&lt;/a&gt;, you’ll take a quick look at an exception that’s a bit different than the others.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-exceptions/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-exceptions/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #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>Gemini 4 Argon Draws a Python Reading a Book</title>
      <id>https://realpython.com/ai-benchmark-gemini-4-argon/</id>
      <link href="https://realpython.com/ai-benchmark-gemini-4-argon/"/>
      <updated>2026-10-14T14:00:00+00:00</updated>
      <summary>Explore Gemini 4 Argon&#x27;s Python code, turtle drawing, and responses to small tasks that check modern syntax, release knowledge, focused edits, and made-up functions.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;We asked &lt;strong&gt;Gemini 4 Argon&lt;/strong&gt; to draw a python reading a book using the &lt;a href=&quot;/ref/stdlib/turtle/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;turtle&lt;/code&gt;&lt;/a&gt; module. It’s one of five tasks in Real Python’s &lt;a href=&quot;https://realpython.com/ai-benchmark/&quot;&gt;informal model comparison&lt;/a&gt;, which explores how models handle everyday Python work. Here’s the drawing from this run:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/turtle.2c3fa0fcacd2.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block border &quot; src=&quot;https://files.realpython.com/media/turtle.2c3fa0fcacd2.png&quot; width=&quot;784&quot; height=&quot;584&quot; srcset=&quot;/cdn-cgi/image/width=196,format=auto/https://files.realpython.com/media/turtle.2c3fa0fcacd2.png 196w, /cdn-cgi/image/width=261,format=auto/https://files.realpython.com/media/turtle.2c3fa0fcacd2.png 261w, /cdn-cgi/image/width=392,format=auto/https://files.realpython.com/media/turtle.2c3fa0fcacd2.png 392w, /cdn-cgi/image/width=784,format=auto/https://files.realpython.com/media/turtle.2c3fa0fcacd2.png 784w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;A python reading a book, drawn with Python&#x27;s turtle module by Gemini 4 Argon.&quot; data-asset=&quot;7839&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_cardd2eb1f&quot;&gt;
&lt;div class=&quot;card-header border-0&quot;&gt;
&lt;p class=&quot;m-0&quot;&gt;
    &lt;button class=&quot;btn w-100&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#collapsed2eb1f&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapsed2eb1f&quot; markdown&gt;&lt;span class=&quot;float-start&quot; markdown&gt;Watch it draw&lt;/span&gt;&lt;span class=&quot;float-end text-muted&quot;&gt;Show/Hide&lt;/span&gt;&lt;/button&gt;
  &lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;collapse js-collapsible-section&quot; data-bs-parent=&quot;#collapse_cardd2eb1f&quot; id=&quot;collapsed2eb1f&quot;&gt;
&lt;div class=&quot;card-body&quot;&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/turtle.6f3e58ce2d85.gif&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block border &quot; src=&quot;https://files.realpython.com/media/turtle.6f3e58ce2d85.gif&quot; width=&quot;784&quot; height=&quot;584&quot; srcset=&quot;/cdn-cgi/image/width=196,format=auto/https://files.realpython.com/media/turtle.6f3e58ce2d85.gif 196w, /cdn-cgi/image/width=261,format=auto/https://files.realpython.com/media/turtle.6f3e58ce2d85.gif 261w, /cdn-cgi/image/width=392,format=auto/https://files.realpython.com/media/turtle.6f3e58ce2d85.gif 392w, /cdn-cgi/image/width=784,format=auto/https://files.realpython.com/media/turtle.6f3e58ce2d85.gif 784w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Turtle animation of Gemini 4 Argon drawing a python reading a book.&quot; data-asset=&quot;7840&quot;&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_card2424bc&quot;&gt;
&lt;div class=&quot;card-header border-0&quot;&gt;
&lt;p class=&quot;m-0&quot;&gt;
    &lt;button class=&quot;btn w-100&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#collapse2424bc&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapse2424bc&quot; markdown&gt;&lt;span class=&quot;float-start&quot; markdown&gt;New here? What the five tasks measure&lt;/span&gt;&lt;span class=&quot;float-end text-muted&quot;&gt;Show/Hide&lt;/span&gt;&lt;/button&gt;
  &lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;collapse js-collapsible-section&quot; data-bs-parent=&quot;#collapse_card2424bc&quot; id=&quot;collapse2424bc&quot;&gt;
&lt;div class=&quot;card-body&quot;&gt;
&lt;p&gt;We use the same prompts and no system prompt for each model. The results come from the returned code and replies. These informal tests explore a few habits that can affect your everyday Python work:&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;Task&lt;/th&gt;
&lt;th&gt;What we ask&lt;/th&gt;
&lt;th&gt;What we read off the answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;The snake&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Write a &lt;a href=&quot;https://realpython.com/beginners-guide-python-turtle/&quot;&gt;Python turtle&lt;/a&gt; program that draws a python reading a book.&lt;/td&gt;
&lt;td&gt;We run the script under a virtual display and record every drawing command. The picture is whatever came out, arrow and all.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;How modern its Python is&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Write a small command-line tool.&lt;/td&gt;
&lt;td&gt;Which features it uses, such as &lt;code&gt;list[str]&lt;/code&gt;, &lt;code&gt;tomllib&lt;/code&gt;, and &lt;code&gt;Path.walk()&lt;/code&gt;. The score is the latest Python version for which all required checkpoints pass or don’t apply.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modern idioms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The same CLI tool as above.&lt;/td&gt;
&lt;td&gt;How many of the idioms we check for came out modern, out of those that applied to the model’s code.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Latest Python version reported&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Which Python release is the newest?&lt;/td&gt;
&lt;td&gt;Whether its answer is up to date. This doesn’t establish its training cutoff.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Unrelated edits&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Add an &lt;code&gt;--ext&lt;/code&gt; option to a 50-line script.&lt;/td&gt;
&lt;td&gt;The script works but has ten spots that are easy to tidy up, like an unused import, &lt;code&gt;%&lt;/code&gt; formatting, and a typo in a comment. None of them is part of the task. We list the ones the model changed anyway. Inspect the diff to see whether those changes were useful.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Spots a made-up function?&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;How do I use &lt;code&gt;itertools.flatten()&lt;/code&gt;?&lt;/td&gt;
&lt;td&gt;That function doesn’t exist. &lt;strong&gt;Caught it&lt;/strong&gt; means the model said so. &lt;strong&gt;Sidestepped it&lt;/strong&gt; means it quietly showed a real alternative without mentioning that. &lt;strong&gt;Fell for it&lt;/strong&gt; means it invented an answer.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reasoning effort&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;The thinking setting we ran with. &lt;strong&gt;default&lt;/strong&gt; means we left the model’s own setting alone, which is how most people use it. The token count is how much thinking the API reported.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;What the API charged for all five tasks, in US dollars. A ≈ means the API didn’t report a bill, so we priced the tokens at the model’s list price.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;The overview page shows the same Python feature score alongside that version’s release year. Code can use newer features and still receive a lower score.&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;New Model Drops? We Run the Bench:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/ai-benchmark-newsletter/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-ai-benchmark-newsletter&quot; markdown&gt;Join the Real Python Newsletter&lt;/a&gt; to get every new AI benchmark run and the full write-ups in your inbox, plus weekly Python tutorials, the moment they land.&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;


&lt;learning-path-card data-path-id=&quot;coding-with-ai&quot; class=&quot;resource-card border rounded overflow-hidden shadow-sm position-relative mb-4&quot; data-progress-card&gt;

    &lt;a class=&quot;resource-card__media&quot; href=&quot;/learning-paths/coding-with-ai/&quot; aria-hidden=&quot;true&quot; tabindex=&quot;-1&quot; data-not-previewable&gt;

      &lt;img loading=&quot;lazy&quot; src=&quot;https://files.realpython.com/media/Coding-With-AI-Learning-Path_Watermarked.5c81f9fcda0d.jpg&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Coding-With-AI-Learning-Path_Watermarked.5c81f9fcda0d.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Coding-With-AI-Learning-Path_Watermarked.5c81f9fcda0d.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Coding-With-AI-Learning-Path_Watermarked.5c81f9fcda0d.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Coding-With-AI-Learning-Path_Watermarked.5c81f9fcda0d.jpg 1920w&quot; alt=&quot;A person standing next to a brain under a dome representing artificial intelligence. The person is relaxed and supervising the AI doing work on the computer.&quot; width=&quot;1920&quot; height=&quot;1080&quot; sizes=&quot;(min-width: 1200px) 172px, (min-width: 1000px) 152px, (min-width: 780px) 142px, (min-width: 580px) 166px, calc(100vw - 32px)&quot; style=&quot;background-color: #fe7e73;&quot;&gt;
    &lt;/a&gt;

  &lt;div class=&quot;resource-card__body&quot;&gt;
    &lt;p class=&quot;small text-muted mb-0&quot;&gt;&lt;strong&gt;Learning Path&lt;/strong&gt;&lt;/p&gt;
    &lt;a class=&quot;stretched-link&quot; href=&quot;/learning-paths/coding-with-ai/&quot;&gt;&lt;h2 class=&quot;my-0 h3&quot;&gt;Python Coding With AI&lt;/h2&gt;&lt;/a&gt;
    &lt;p class=&quot;text-muted mb-0 small&quot;&gt;12 Resources ⋅ &lt;strong&gt;Skills:&lt;/strong&gt; Cursor, Claude Code, AI-Assisted Development, Context Engineering, AI Code Review&lt;/p&gt;


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


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

&lt;h2 id=&quot;the-results-at-a-glance&quot;&gt;The Results at a Glance&lt;a class=&quot;headerlink&quot; href=&quot;#the-results-at-a-glance&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&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;Task&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The snake&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Drew it&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;521 drawing commands, 216 lines of code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How modern its Python is&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Python 3.10&lt;/strong&gt; (2021)&lt;/td&gt;
&lt;td&gt;pinned by &lt;code&gt;datetime_utc&lt;/code&gt;. Newest feature used: Python 3.12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern idioms&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;12 of 15&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;of the checkpoints that applied to its code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latest Python version reported&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;no version given&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;the reply is quoted below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unrelated edits&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0 of 10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;left every unrelated spot alone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spots a made-up function?&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Caught it&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;said the function doesn’t exist and offered a real alternative&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reasoning effort&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;default&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;no thinking tokens reported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.06&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;for all 5 tasks, as billed by the API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Response time&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1 min 11 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5.4k output tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_card1f0004&quot;&gt;
&lt;div class=&quot;card-header border-0&quot;&gt;
&lt;p class=&quot;m-0&quot;&gt;
    &lt;button class=&quot;btn w-100&quot; data-bs-toggle=&quot;collapse&quot; data-bs-target=&quot;#collapse1f0004&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapse1f0004&quot; markdown&gt;&lt;span class=&quot;float-start&quot; markdown&gt;Run settings&lt;/span&gt;&lt;span class=&quot;float-end text-muted&quot;&gt;Show/Hide&lt;/span&gt;&lt;/button&gt;
  &lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;collapse js-collapsible-section&quot; data-bs-parent=&quot;#collapse_card1f0004&quot; id=&quot;collapse1f0004&quot;&gt;
&lt;div class=&quot;card-body&quot;&gt;
&lt;p&gt;The run: &lt;code&gt;google/gemini-4-argon&lt;/code&gt; via OpenRouter, at its default reasoning settings, with no system prompt and the returned code left unchanged.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/ai-benchmark-gemini-4-argon/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ai-benchmark-gemini-4-argon/ »&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 Project Structure: How to Choose the Right Layout</title>
      <id>https://realpython.com/python-application-layouts/</id>
      <link href="https://realpython.com/python-application-layouts/"/>
      <updated>2026-10-14T14:00:00+00:00</updated>
      <summary>Learn how to structure Python projects: pick between flat and src/ layouts, organize your code, and apply the patterns to CLI, web, and GUI apps.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Your Python project structure, also known as your project layout, is the arrangement of files and directories that determines how your code gets imported, tested, and packaged. Choosing between a flat and a &lt;code&gt;src/&lt;/code&gt; layout depends on the type of project you’re building and the trade-offs you accept.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll turn those choices into confident defaults for libraries and for CLI, web, and GUI applications.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;type of project&lt;/strong&gt; you build, whether a script, an application, or a library, points to the layout that fits.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;flat layout&lt;/strong&gt; keeps the importable package at the project root, so you can import it without installing anything.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;&lt;code&gt;src/&lt;/code&gt; layout&lt;/strong&gt; hides the package behind an install step, so your tests exercise the same code your users receive.&lt;/li&gt;
&lt;li&gt;A thin &lt;code&gt;__main__.py&lt;/code&gt; paired with a &lt;code&gt;[project.scripts]&lt;/code&gt; table in &lt;code&gt;pyproject.toml&lt;/code&gt; is the modern way to define the project’s &lt;strong&gt;entry point&lt;/strong&gt;, and it replaces older approaches like &lt;code&gt;setup.py&lt;/code&gt; or a &lt;code&gt;bin/&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Domain-named subpackages&lt;/strong&gt; like &lt;code&gt;core/&lt;/code&gt; and &lt;code&gt;api/&lt;/code&gt; scale better than catch-all modules like &lt;code&gt;utils.py&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To follow along, it helps if you’re comfortable with &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;Python modules and packages&lt;/a&gt; and if you’ve &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run a script&lt;/a&gt; or two from the command line.&lt;/p&gt;
&lt;p&gt;You won’t install anything or build a full application here. Instead, several annotated directory trees will show you why each file belongs where it does.&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-project-structure-cheatsheet/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-project-structure-cheatsheet&quot; markdown&gt;Click here to download your free Python project structure cheat sheet&lt;/a&gt; and keep the flat vs. src/ decision and the entry-point wiring within reach on your next project.&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 Project Structure: How to Choose the Right Layout” 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-application-layouts/&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: #abe5b2;&quot; alt=&quot;A person at a drafting machine arranges labeled cards on a layout board beside signs reading LAYOUTS, flat, src, and ORGANIZE MODULES ENTRY POINT SUBPACKAGES, with a Python logo.&quot; src=&quot;https://files.realpython.com/media/Python-Project-Structure-A-Reference-for-Application-Layouts_Watermarked.f845a3dfb2df.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-Project-Structure-A-Reference-for-Application-Layouts_Watermarked.f845a3dfb2df.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Python-Project-Structure-A-Reference-for-Application-Layouts_Watermarked.f845a3dfb2df.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Python-Project-Structure-A-Reference-for-Application-Layouts_Watermarked.f845a3dfb2df.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Python-Project-Structure-A-Reference-for-Application-Layouts_Watermarked.f845a3dfb2df.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-application-layouts/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Python Project Structure: How to Choose the Right Layout&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of Python project structure, from flat and src layouts to organizing packages for CLI, web, and GUI applications.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;understanding-why-python-project-structure-matters&quot;&gt;Understanding Why Python Project Structure Matters&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-why-python-project-structure-matters&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A directory layout can feel like bookkeeping, but it shapes every interaction that you and your teammates have with the code. The payoff of a clear layout shows up in several concrete ways, including the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lower cognitive load&lt;/strong&gt;: When every file sits in a descriptively named directory and has a name that signals what it holds, a contributor who opens the repository for the first time can guess where things live instead of grepping around.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Predictable imports&lt;/strong&gt;: When your directories mirror the way you import them, you can read a module’s dotted import name straight off the directory tree rather than hunting for where it lives.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reliable tests&lt;/strong&gt;: When your tests find the package and modules just as your users will, &lt;a href=&quot;https://realpython.com/pytest-python-testing/&quot;&gt;running &lt;code&gt;pytest&lt;/code&gt;&lt;/a&gt; behaves the same in &lt;a href=&quot;/ref/software-engineering-glossary/continuous-integration/&quot; class=&quot;ref-link&quot;&gt;continuous integration&lt;/a&gt; (CI) as it does on your computer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Smooth packaging&lt;/strong&gt;: When you ship a library to &lt;a href=&quot;/ref/glossary/pypi/&quot; class=&quot;ref-link&quot;&gt;PyPI&lt;/a&gt;, build a CLI binary, deploy a web service in a container, or freeze a desktop app with PyInstaller, the right layout means the &lt;a href=&quot;/ref/glossary/wheel/&quot; class=&quot;ref-link&quot;&gt;wheel&lt;/a&gt;, installer, or image holds exactly what you expect. You end up with no missing assets, no stowaway test files, and no broken entry points.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of these benefits rest on a vocabulary distinction worth getting straight early. The &lt;em&gt;project&lt;/em&gt; is the whole repository, including its configuration, tests, and documentation. The &lt;em&gt;package&lt;/em&gt; is the importable code that lives inside the project. Keeping the two ideas separate makes the rest of this tutorial click into place because most layout questions come down to where the package sits relative to everything else.&lt;/p&gt;
&lt;p&gt;If you want a refresher on the import machinery behind these ideas, then the &lt;a href=&quot;/ref/best-practices/project-layout/&quot; class=&quot;ref-link&quot;&gt;project layout&lt;/a&gt; reference makes a good companion. With the vocabulary in hand, you can start narrowing your options by naming the type of project that you’re building.&lt;/p&gt;
&lt;h2 id=&quot;identifying-the-type-of-project-youre-building&quot;&gt;Identifying the Type of Project You’re Building&lt;a class=&quot;headerlink&quot; href=&quot;#identifying-the-type-of-project-youre-building&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you start learning about layouts, you need to know what you’re laying out. Python projects fall into three broad types, and each one has its own &lt;em&gt;typical&lt;/em&gt; layout:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scripts&lt;/strong&gt;: One or a few &lt;code&gt;.py&lt;/code&gt; files that you run directly. They need no installation and often no &lt;code&gt;pyproject.toml&lt;/code&gt;, or at most a &lt;a href=&quot;https://peps.python.org/pep-0723/&quot;&gt;PEP 723&lt;/a&gt; inline header. A data-cleanup script or a &lt;a href=&quot;https://en.wikipedia.org/wiki/Cron&quot;&gt;&lt;code&gt;cron&lt;/code&gt; job&lt;/a&gt; fits here.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Applications&lt;/strong&gt;: Software that you run or deploy, rather than code that others import. This is where Python application structure varies the most, covering &lt;a href=&quot;/ref/glossary/command-line-interface/&quot; class=&quot;ref-link&quot;&gt;CLIs&lt;/a&gt;, web apps, &lt;a href=&quot;/ref/glossary/graphical-user-interface/&quot; class=&quot;ref-link&quot;&gt;GUI&lt;/a&gt; apps, and background workers. Web apps use frameworks like Django, Flask, or FastAPI, while GUI apps rely on tools like &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/&quot;&gt;PyQt&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-gui-tkinter/&quot;&gt;Tkinter&lt;/a&gt;, Toga, or &lt;a href=&quot;https://realpython.com/mobile-app-kivy-python/&quot;&gt;Kivy&lt;/a&gt;. You ship them as a container, a wheel, or an installer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Libraries&lt;/strong&gt;: Importable code that other projects depend on. You can distribute a library through PyPI, and your users consume it with &lt;code&gt;import package_name&lt;/code&gt;. Familiar examples include &lt;a href=&quot;https://realpython.com/python-requests/&quot;&gt;requests&lt;/a&gt;, HTTPX, and &lt;a href=&quot;https://realpython.com/python-rich-package/&quot;&gt;Rich&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A couple of cases sit at the edges of this taxonomy and could cause confusion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;plugin&lt;/strong&gt;, like &lt;code&gt;pytest-cov&lt;/code&gt;, is a specialized library that gets consumed through a &lt;code&gt;[project.entry-points]&lt;/code&gt; table in &lt;code&gt;pyproject.toml&lt;/code&gt; instead of a direct &lt;code&gt;import&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;hybrid&lt;/strong&gt;, like &lt;code&gt;pytest&lt;/code&gt;, &lt;a href=&quot;/ref/tools/mypy/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;mypy&lt;/code&gt;&lt;/a&gt;, or &lt;a href=&quot;/ref/tools/black/&quot; class=&quot;ref-link&quot;&gt;&lt;code&gt;black&lt;/code&gt;&lt;/a&gt;, ships as both a library and a command-line tool. The structural rule is to build the project around the more demanding half, usually the library, and then add the CLI as a thin &lt;code&gt;cli.py&lt;/code&gt; with a &lt;code&gt;[project.scripts]&lt;/code&gt; entry.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Naming the project type is the first step of the layout decision because the type alone points you to a default you can adopt unless you have a reason not to:&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;Project Type&lt;/th&gt;
&lt;th&gt;Typical Layout&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Scripts&lt;/td&gt;
&lt;td&gt;None (flat if it grows)&lt;/td&gt;
&lt;td&gt;A script is barely a project, and a flat layout with &lt;code&gt;pyproject.toml&lt;/code&gt; is the natural next step.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Applications&lt;/td&gt;
&lt;td&gt;Flat&lt;/td&gt;
&lt;td&gt;Most web frameworks scaffold projects flat, and you switch to &lt;code&gt;src/&lt;/code&gt; when packaging or wheel deployment matters.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Libraries&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Installation is part of the user contract, since you mostly distribute through PyPI or a private index.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;This table shows where you’ll end up. Here’s a short, repeatable workflow that you’ll follow throughout the rest of this tutorial:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Identify the type of Python project.&lt;/li&gt;
&lt;li&gt;Pick a layout.&lt;/li&gt;
&lt;li&gt;Organize the package from the inside out.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Those three steps will guide your decision-making, starting with the type of project you’re building and the layout it points to:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/diagram-python-application-layouts-decision.28d246639a35.svg&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/diagram-python-application-layouts-decision.28d246639a35.svg&quot; width=&quot;487&quot; height=&quot;384&quot; alt=&quot;Scripts and applications typically use a flat layout, libraries a src/ layout, and applications switch to src/ when packaging matters.&quot; data-asset=&quot;7212&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Choosing a Layout by Project Type&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;With the project type settled, take a closer look at the two main layouts that cover nearly every Python project.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-application-layouts/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-application-layouts/ »&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 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>Docling vs LlamaParse: How to Extract PDF Tables in Python</title>
      <id>https://realpython.com/extract-table-from-pdf-python/</id>
      <link href="https://realpython.com/extract-table-from-pdf-python/"/>
      <updated>2026-10-12T14:00:00+00:00</updated>
      <summary>Learn how to extract tables from a PDF in Python with Docling and LlamaParse, and compare local parsing against a cloud API on speed and cost.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Choosing between Docling and LlamaParse comes down to how you want to extract tables from a PDF in Python: on your own machine or in the cloud. Docling runs locally as an open-source library, while LlamaParse parses through an LLM-guided cloud pipeline. This tutorial builds the same table extractor twice to compare quality, setup, output formats, speed, and cost using a single sample PDF.&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;IBM’s Docling parses &lt;strong&gt;entirely on your own machine&lt;/strong&gt;, needs no API key, and adds no per-document cost.&lt;/li&gt;
&lt;li&gt;LlamaIndex’s LlamaParse uploads every PDF to the &lt;strong&gt;cloud&lt;/strong&gt; and parses it through tiers from &lt;code&gt;fast&lt;/code&gt; to &lt;code&gt;agentic_plus&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Docling exports straight to &lt;strong&gt;Markdown, JSON, HTML, and pandas DataFrames&lt;/strong&gt;, while LlamaParse splits the work across a Parse path and an Extract path.&lt;/li&gt;
&lt;li&gt;Docling applies a fixed &lt;strong&gt;layout-detection stack&lt;/strong&gt;, whereas LlamaParse interprets each page with an &lt;strong&gt;LLM&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On a ten-page financial PDF, LlamaParse finished in about &lt;strong&gt;30 seconds&lt;/strong&gt; versus roughly &lt;strong&gt;82 seconds&lt;/strong&gt; for Docling on CPU.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both parsers in this tutorial target the same &lt;code&gt;sample_report.pdf&lt;/code&gt;, a table-heavy ten-page excerpt from an SEC 10-K filing, so you can compare their output directly.&lt;/p&gt;
&lt;p&gt;You should be comfortable installing Python packages and running scripts from the terminal. Familiarity with &lt;a href=&quot;https://realpython.com/working-with-files-in-python/&quot;&gt;files in Python&lt;/a&gt; helps, plus &lt;a href=&quot;https://realpython.com/pandas-dataframe/&quot;&gt;pandas DataFrames&lt;/a&gt; if you want DataFrame output.&lt;/p&gt;
&lt;p&gt;You’ll also need the following before diving into this tutorial:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 3.10 or newer:&lt;/strong&gt; Docling requires at least Python 3.10. Although LlamaParse also runs on 3.9, using the same minimum keeps both tools in a single environment. If you’re not sure which version you have, then run &lt;code&gt;python --version&lt;/code&gt; in your terminal. If you need to install or upgrade, follow the steps in the guide on &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;installing Python&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;LlamaCloud account (LlamaParse only):&lt;/strong&gt; You’ll need this account to generate an API key. Never paste your API key directly into source code. Store it as the &lt;code&gt;LLAMA_CLOUD_API_KEY&lt;/code&gt; &lt;a href=&quot;/ref/computer-science-glossary/environment-variable-env-var/&quot; class=&quot;ref-link&quot;&gt;environment variable&lt;/a&gt; instead. The setup section below shows how to install the SDK and export the key for your operating system.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sample PDF:&lt;/strong&gt; Keep &lt;code&gt;sample_report.pdf&lt;/code&gt; in your working directory. You can find it in the tutorial downloads if you want to follow along.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Virtual environment:&lt;/strong&gt; Create and activate one before installing any packages. If virtual environments are new to you, then &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;Python Virtual Environments: A Primer&lt;/a&gt; will get you up to speed.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The exact commands depend on your operating system:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-1&quot; data-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;py&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;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-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;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;venv&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;.venv
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;.venv/bin/activate
&lt;/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;Don’t worry if you’ve never parsed a PDF programmatically. This tutorial walks you through installation from scratch, a first parse, and a side-by-side output comparison.&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/extract-table-from-pdf-python-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-extract-table-from-pdf-python-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to extract tables from a PDF with Docling and LlamaParse.&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 “Docling vs LlamaParse: How to Extract PDF Tables 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/extract-table-from-pdf-python/&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;Two workers operating side-by-side machines labeled Docling and LlamaParse that take in a PDF from a chute above and print out grids of table data, with a Python logo between them.&quot; src=&quot;https://files.realpython.com/media/PDF-Table-Extraction-in-Python-Docling-vs-LlamaParse_Watermarked.8f46cf95e43c.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/PDF-Table-Extraction-in-Python-Docling-vs-LlamaParse_Watermarked.8f46cf95e43c.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/PDF-Table-Extraction-in-Python-Docling-vs-LlamaParse_Watermarked.8f46cf95e43c.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/PDF-Table-Extraction-in-Python-Docling-vs-LlamaParse_Watermarked.8f46cf95e43c.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/PDF-Table-Extraction-in-Python-Docling-vs-LlamaParse_Watermarked.8f46cf95e43c.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/extract-table-from-pdf-python/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Docling vs LlamaParse: How to Extract PDF Tables in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of extracting PDF tables in Python with Docling and LlamaParse, and of when to parse locally instead of in the cloud.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;metrics-comparison-docling-vs-llamaparse&quot;&gt;Metrics Comparison: Docling vs LlamaParse&lt;a class=&quot;headerlink&quot; href=&quot;#metrics-comparison-docling-vs-llamaparse&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Use this table as an at-a-glance summary of packages, infrastructure requirements, and ballpark performance before the walkthroughs below:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Docling&lt;/th&gt;
&lt;th&gt;LlamaParse&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Python package&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docling&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;llama-cloud&lt;/code&gt; (&amp;gt;=2.9.0)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minimum Python version&lt;/td&gt;
&lt;td&gt;3.10&lt;/td&gt;
&lt;td&gt;3.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Additional downloads on first run&lt;/td&gt;
&lt;td&gt;Yes, layout and table models (~500–600 MB)&lt;/td&gt;
&lt;td&gt;No, parsing runs in the cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Time to first parse (fresh install)&lt;/td&gt;
&lt;td&gt;Slower, model download first&lt;/td&gt;
&lt;td&gt;Faster, &lt;code&gt;pip&lt;/code&gt; and API key only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API key required&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes, &lt;code&gt;LLAMA_CLOUD_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Documents leave your machine&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes, PDFs are uploaded for server-side parsing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internet required at parse time&lt;/td&gt;
&lt;td&gt;No, once models are cached&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Marginal cost per document&lt;/td&gt;
&lt;td&gt;$0 (local compute only)&lt;/td&gt;
&lt;td&gt;Free tier of 10,000 credits per month, then paid tiers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Parse tiers&lt;/td&gt;
&lt;td&gt;Not applicable (single local pipeline)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fast&lt;/code&gt;, &lt;code&gt;cost_effective&lt;/code&gt;, &lt;code&gt;agentic&lt;/code&gt;, &lt;code&gt;agentic_plus&lt;/code&gt; (tutorial uses &lt;code&gt;agentic&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical parse time (ten-page PDF, see &lt;a href=&quot;#benchmarks-timing-the-same-pdf&quot;&gt;Benchmarks&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;~10–20 s (text-heavy), ~60–90 s (table-heavy) on CPU&lt;/td&gt;
&lt;td&gt;~30 s over the network on the sample PDF (not tied to local CPU)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU support&lt;/td&gt;
&lt;td&gt;Optional, speeds up layout analysis&lt;/td&gt;
&lt;td&gt;Not applicable (server-side)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Primary maintainer&lt;/td&gt;
&lt;td&gt;IBM Research (open source, MIT)&lt;/td&gt;
&lt;td&gt;LlamaIndex (managed SaaS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best-known strength&lt;/td&gt;
&lt;td&gt;Structured local pipelines, DataFrame export&lt;/td&gt;
&lt;td&gt;Zero-infra setup, charts and unusual layouts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The &lt;code&gt;llama-parse&lt;/code&gt; and &lt;code&gt;llama-cloud-services&lt;/code&gt; packages were &lt;a href=&quot;https://github.com/run-llama/llama_cloud_services/&quot;&gt;deprecated in May 2026&lt;/a&gt;. See also LlamaIndex’s &lt;a href=&quot;https://www.llamaindex.ai/blog/announcing-new-llamacloud-sdks-and-parse-api-v2&quot;&gt;announcement of the new &lt;code&gt;llama-cloud&lt;/code&gt; SDKs and Parse API v2&lt;/a&gt;. All LlamaParse examples in this tutorial use &lt;code&gt;llama-cloud&amp;gt;=2.9.0&lt;/code&gt;, which targets Parse API v2.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The next section turns this comparison into a practical recommendation.&lt;/p&gt;
&lt;h2 id=&quot;setup-and-operational-model&quot;&gt;Setup and Operational Model&lt;a class=&quot;headerlink&quot; href=&quot;#setup-and-operational-model&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For day-to-day work, the practical details matter most: how you install each tool, whether you need an API key, and where the parsing runs. Every example below uses the same &lt;code&gt;sample_report.pdf&lt;/code&gt; from the tutorial downloads, so you can compare output directly.&lt;/p&gt;
&lt;h3 id=&quot;docling-open-source-parsing-on-your-own-machine&quot;&gt;Docling: Open-Source Parsing on Your Own Machine&lt;a class=&quot;headerlink&quot; href=&quot;#docling-open-source-parsing-on-your-own-machine&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Docling installs like any other Python library, but its default OCR engine, RapidOCR, prefers the &lt;code&gt;onnxruntime&lt;/code&gt; backend, which a plain &lt;code&gt;pip install docling&lt;/code&gt; doesn’t include:&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 gp-VirtualEnv&quot;&gt;(.venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;docling==2.102.2&quot;&lt;/span&gt;
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(.venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-m&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;pip&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;install&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;onnxruntime&amp;gt;=1.7.0,&amp;lt;2.0.0&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; aria-label=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;icon baseline&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.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 two packages give Docling its core converter and the OCR backend that this tutorial expects.&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; Without &lt;code&gt;onnxruntime&lt;/code&gt;, parsing still completes on Docling 2.102.2. Auto OCR skips the &lt;code&gt;onnxruntime&lt;/code&gt; RapidOCR path, skips EasyOCR if it isn’t installed, then selects RapidOCR with the &lt;code&gt;torch&lt;/code&gt; backend that already ships with Docling. At the info level, you see lines like:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;text&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--grey&quot;&gt;
    &lt;span class=&quot;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Text&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;rapidocr cannot be used because onnxruntime is not installed.
easyocr cannot be used because it is not installed.
Auto OCR model selected rapidocr with torch.
&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 &lt;code&gt;torch&lt;/code&gt; fallthrough isn’t the path this tutorial targets, so install &lt;code&gt;onnxruntime&lt;/code&gt; as shown above.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/extract-table-from-pdf-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/extract-table-from-pdf-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Quiz: 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>Functional Programming in Python: When and How to Use It</title>
      <id>https://realpython.com/python-functional-programming/</id>
      <link href="https://realpython.com/python-functional-programming/"/>
      <updated>2026-10-11T14:00:00+00:00</updated>
      <summary>See how Python supports functional programming, what the paradigm actually is, and where it fits in the code you write day to day.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;strong&gt;Functional programming&lt;/strong&gt; is a programming paradigm in which the primary method of computation is the evaluation of functions. But how does Python support functional programming?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What the &lt;strong&gt;functional programming&lt;/strong&gt; paradigm entails&lt;/li&gt;
&lt;li&gt;What it means to say that &lt;strong&gt;functions&lt;/strong&gt; are &lt;strong&gt;first-class citizens&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;How to define &lt;strong&gt;anonymous functions&lt;/strong&gt; with the &lt;strong&gt;&lt;code&gt;lambda&lt;/code&gt;&lt;/strong&gt; keyword&lt;/li&gt;
&lt;li&gt;How to implement functional code using &lt;strong&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;code&gt;reduce()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Functional programming typically plays a minor role in Python code, but it’s still good to be familiar with it. You’ll probably encounter it from time to time when reading code written by others. And you may even find situations where it’s advantageous to use Python’s functional programming capabilities in your own code.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-functional-programming-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-functional-programming-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you when and how to use  functional programming 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 “Functional Programming in Python: When and How to Use It” 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-functional-programming/&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: #abe5b2;&quot; alt=&quot;Functional Programming in Python: When and How to Use It&quot; src=&quot;https://files.realpython.com/media/TUT19---Functional-Programming_Watermarked.7c5a8382c298.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/TUT19---Functional-Programming_Watermarked.7c5a8382c298.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/TUT19---Functional-Programming_Watermarked.7c5a8382c298.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/TUT19---Functional-Programming_Watermarked.7c5a8382c298.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/TUT19---Functional-Programming_Watermarked.7c5a8382c298.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-functional-programming/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Functional Programming in Python: When and How to Use It&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 functional programming in Python. You&#x27;ll revisit concepts such as functions being first-class citizens in Python, the use of the lambda keyword, and the implementation of functional code using map(), filter(), and reduce().&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;what-is-functional-programming&quot;&gt;What Is Functional Programming?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-functional-programming&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;pure function&lt;/strong&gt; is a function whose output value follows solely from its input values without any observable &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/#side-effects&quot;&gt;side effects&lt;/a&gt;. In &lt;strong&gt;functional programming&lt;/strong&gt;, a program consists primarily of the evaluation of pure functions. Computation proceeds by nested or &lt;a href=&quot;https://en.wikipedia.org/wiki/Function_composition_(computer_science)&quot;&gt;composed function calls&lt;/a&gt; without changes to state or &lt;a href=&quot;/ref/glossary/mutable/&quot; class=&quot;ref-link&quot;&gt;mutable&lt;/a&gt; data.&lt;/p&gt;
&lt;p&gt;The functional paradigm is popular because it offers several advantages over other programming paradigms. Functional code is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;High level:&lt;/strong&gt; You describe the result you want rather than explicitly specifying the steps required to get there. Single statements tend to be concise but pack a lot of punch.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transparent:&lt;/strong&gt; The behavior of a pure function can be described by its inputs and outputs, without intermediary values. This eliminates the possibility of side effects and facilitates &lt;a href=&quot;https://realpython.com/python-debugging-pdb/&quot;&gt;debugging&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallelizable:&lt;/strong&gt; Routines that don’t cause side effects can more easily &lt;a href=&quot;https://realpython.com/learning-paths/python-concurrency-parallel-programming/&quot;&gt;run in parallel&lt;/a&gt; with one another.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Many programming languages support some degree of functional programming. In some languages, virtually all code follows the functional paradigm. &lt;a href=&quot;https://www.haskell.org&quot;&gt;Haskell&lt;/a&gt; is one such example. Python, by contrast, does support functional programming but contains features of other programming models as well.&lt;/p&gt;
&lt;p&gt;While it’s true that an in-depth description of &lt;a href=&quot;https://en.wikipedia.org/wiki/Functional_programming&quot;&gt;functional programming&lt;/a&gt; is somewhat complex, the goal here isn’t to present a rigorous definition but to show you what you can do by way of functional programming in Python.&lt;/p&gt;
&lt;h2 id=&quot;how-well-does-python-support-functional-programming&quot;&gt;How Well Does Python Support Functional Programming?&lt;a class=&quot;headerlink&quot; href=&quot;#how-well-does-python-support-functional-programming&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To support functional programming, it’s beneficial if a &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;function&lt;/a&gt; in a given programming language can do these two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Take another function as an &lt;a href=&quot;/ref/glossary/argument/&quot; class=&quot;ref-link&quot;&gt;argument&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Return another function to its caller&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Python plays nicely in both respects. Everything in Python is an &lt;a href=&quot;https://realpython.com/python-variables/#object-references&quot;&gt;object&lt;/a&gt;, and all objects in Python have more or less equal stature. Functions are no exception.&lt;/p&gt;
&lt;p&gt;In Python, functions are &lt;strong&gt;first-class citizens&lt;/strong&gt;. This means that functions have the same characteristics as values like &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;. Anything you would expect to be able to do with a string or number, you can also do with a function.&lt;/p&gt;
&lt;p&gt;For example, you can assign a function to a &lt;a href=&quot;/ref/glossary/variable/&quot; class=&quot;ref-link&quot;&gt;variable&lt;/a&gt;. You can then use that variable the same way you would use the function itself:&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;linenos&quot;&gt; 1&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;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;I am function func()!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;I am function func()!&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;linenos&quot;&gt; 8&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;another_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;linenos&quot;&gt; 9&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;another_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;I am function func()!&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 &lt;a href=&quot;/ref/glossary/assignment/&quot; class=&quot;ref-link&quot;&gt;assignment&lt;/a&gt; &lt;code&gt;another_name = func&lt;/code&gt; on line 8 creates a new reference to &lt;code&gt;func()&lt;/code&gt; named &lt;code&gt;another_name&lt;/code&gt;. You can then call the function by either of the two names, &lt;code&gt;func&lt;/code&gt; or &lt;code&gt;another_name&lt;/code&gt;, as shown on lines 5 and 9.&lt;/p&gt;
&lt;p&gt;You can display a function to the console with &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt;, include it as an element in a composite data object like a &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list&lt;/a&gt;, or even use it as a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt; key:&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;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;I am function func()!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&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&gt;&lt;span class=&quot;go&quot;&gt;cat &amp;lt;function func at 0x7f81b4d29bf8&amp;gt; 42&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&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&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;function func at 0x7f81b4d29bf8&amp;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;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;I am function func()!&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cat&quot;&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;n&quot;&gt;func&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;42&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&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;func&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;In this example, &lt;code&gt;func()&lt;/code&gt; appears in all the same contexts as the values &lt;code&gt;&quot;cat&quot;&lt;/code&gt; and &lt;code&gt;42&lt;/code&gt;, and the &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt; handles it just fine.&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; What you can or can’t do with an object in Python depends to some extent on context. Some operations work for certain object &lt;a href=&quot;/ref/glossary/type/&quot; class=&quot;ref-link&quot;&gt;types&lt;/a&gt; but not for others.&lt;/p&gt;
&lt;p&gt;For example, you can add two integer objects or &lt;a href=&quot;https://realpython.com/python-string-concatenation/&quot;&gt;concatenate&lt;/a&gt; two string objects with the plus operator (&lt;code&gt;+&lt;/code&gt;), but the plus operator isn’t defined for function objects.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;For present purposes, what matters is that functions in Python satisfy the two criteria beneficial for functional programming listed above. You can pass a function to another function as an argument:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-functional-programming/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-functional-programming/ »&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: 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>Quiz: Generate Images in Python With OpenAI&#x27;s GPT Image API</title>
      <id>https://realpython.com/quizzes/generate-images-openai/</id>
      <link href="https://realpython.com/quizzes/generate-images-openai/"/>
      <updated>2026-10-09T12:00:00+00:00</updated>
      <summary>Test your understanding of generating images in Python with OpenAI&#x27;s GPT Image models, from text prompts and Base64 decoding to size, quality, and edits.</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/generate-images-openai/&quot;&gt;Generate Images in Python With OpenAI&amp;rsquo;s GPT Image API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to install the OpenAI Python library, store your API key, generate images from text prompts with the GPT Image models, tune their size and quality, decode Base64 responses into PNG files, and edit an image with a follow-up prompt.&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 Basics Exercises: Strings and String Methods</title>
      <id>https://realpython.com/quizzes/python-exercises-string-methods/</id>
      <link href="https://realpython.com/quizzes/python-exercises-string-methods/"/>
      <updated>2026-10-09T12:00:00+00:00</updated>
      <summary>Practice Python string methods. Slice strings, change their case, strip whitespace, and format text for printing in this quiz for beginners.</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/python-exercises-string-methods/&quot;&gt;Python Basics Exercises: Strings and String Methods&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to slice strings, change their case,
strip whitespace, check how a string starts, chain string methods together, and format
values for printing.&lt;/p&gt;
&lt;p&gt;Working with text is one of the most common tasks in Python, so these skills will come
up again and again. Take your time with each question, and read the explanations to
reinforce what you&amp;rsquo;ve practiced.&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>
