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

  
    <entry>
      <title>Operator and Function Overloading in Custom Python Classes</title>
      <id>https://realpython.com/operator-function-overloading/</id>
      <link href="https://realpython.com/operator-function-overloading/"/>
      <updated>2026-11-01T14:00:00+00:00</updated>
      <summary>Use Python operator overloading to make built-in functions and operators work with your own classes, and write more Pythonic code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’ve used the &lt;code&gt;+&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt; operator on a &lt;code&gt;str&lt;/code&gt; &lt;a href=&quot;/ref/glossary/object/&quot; class=&quot;ref-link&quot;&gt;object&lt;/a&gt; in Python, you must have noticed its different behavior when compared to &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;float&lt;/code&gt; objects:&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.ef3487c363c6.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;# Adds the two numbers&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3&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;# Concatenates the two strings&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Real&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Python&quot;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;RealPython&#x27;&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;# Gives the product&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;6&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;# Repeats the string&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Python&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;PythonPythonPython&#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.ef3487c363c6.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 might have wondered how the same built-in operator or &lt;a href=&quot;/ref/glossary/function/&quot; class=&quot;ref-link&quot;&gt;function&lt;/a&gt; shows different behavior for objects of different classes. This is called operator &lt;a href=&quot;/ref/computer-science-glossary/overloading/&quot; class=&quot;ref-link&quot;&gt;overloading&lt;/a&gt; or function overloading respectively. This article will help you understand this mechanism, so that you can do the same in your own &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;Python classes&lt;/a&gt; and make your objects more &lt;a href=&quot;/ref/glossary/pythonic/&quot; class=&quot;ref-link&quot;&gt;Pythonic&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You’ll learn the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The API that handles operators and built-ins in Python&lt;/li&gt;
&lt;li&gt;The “secret” behind &lt;code&gt;len()&lt;/code&gt; and other built-ins&lt;/li&gt;
&lt;li&gt;How to make your classes capable of using operators&lt;/li&gt;
&lt;li&gt;How to make your classes compatible with Python’s built-in functions&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;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/operator-function-overloading-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-operator-function-overloading-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to overload operators and built-in functions in your own Python classes.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;As a bonus, you’ll also see an example &lt;a href=&quot;/ref/glossary/class/&quot; class=&quot;ref-link&quot;&gt;class&lt;/a&gt;, objects of which will be compatible with many of these operators and functions. Let’s get started!&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.ef3487c363c6.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 “Operator and Function Overloading in Custom Python Classes” 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/operator-function-overloading/&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;Operator and Function Overloading in Python&quot; src=&quot;https://files.realpython.com/media/Operator-and-Function-Overloading-in-Custom-Python-Classes_Watermarked.575229f93a74.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Operator-and-Function-Overloading-in-Custom-Python-Classes_Watermarked.575229f93a74.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Operator-and-Function-Overloading-in-Custom-Python-Classes_Watermarked.575229f93a74.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Operator-and-Function-Overloading-in-Custom-Python-Classes_Watermarked.575229f93a74.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Operator-and-Function-Overloading-in-Custom-Python-Classes_Watermarked.575229f93a74.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.ef3487c363c6.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/operator-function-overloading/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Operator and Function Overloading in Custom Python Classes&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of operator and function overloading in Python. Practice the dunder methods that make your classes work with built-ins.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Object-Oriented Python Live Course:&lt;/strong&gt; Want to make your own classes work naturally with Python’s operators and built-ins? In Real Python’s &lt;a href=&quot;https://realpython.com/workshops/python-oop/&quot;&gt;Object-Oriented Python&lt;/a&gt; live course, you put the data model to work in a complete project, with an instructor guiding your design decisions. Join the waitlist to hear about the next dates.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;the-python-data-model&quot;&gt;The Python Data Model&lt;a class=&quot;headerlink&quot; href=&quot;#the-python-data-model&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Say you have a class representing an online order having a cart (a &lt;a href=&quot;https://realpython.com/python-list/&quot;&gt;&lt;code&gt;list&lt;/code&gt;&lt;/a&gt;) and a customer (a &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;&lt;code&gt;str&lt;/code&gt;&lt;/a&gt; or &lt;a href=&quot;/ref/glossary/instance/&quot; class=&quot;ref-link&quot;&gt;instance&lt;/a&gt; of another &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;class&lt;/a&gt; which represents a customer).&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you need a refresher on OOP in Python, check out this tutorial on Real Python: &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;Object-Oriented Programming (OOP) in Python&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In such a case, it is quite natural to want to obtain the length of the cart list. Someone new to Python might decide to implement a &lt;a href=&quot;/ref/glossary/method/&quot; class=&quot;ref-link&quot;&gt;method&lt;/a&gt; called &lt;code&gt;get_cart_len()&lt;/code&gt; in their class to do this. But you can configure the built-in &lt;a href=&quot;https://realpython.com/len-python-function/&quot;&gt;&lt;code&gt;len()&lt;/code&gt;&lt;/a&gt; in such a way that it returns the length of the cart list when given our object.&lt;/p&gt;
&lt;p&gt;In another case, we might want to append something to the cart. Again, someone new to Python would think of implementing a method called &lt;code&gt;append_to_cart()&lt;/code&gt; that takes an item and appends it to the cart list. But you can configure the &lt;code&gt;+&lt;/code&gt; operator in such a way that it appends a new item to the cart.&lt;/p&gt;
&lt;p&gt;Python does all this using &lt;a href=&quot;https://realpython.com/python-classes/#special-methods-and-protocols&quot;&gt;special methods&lt;/a&gt;. These special methods have a naming convention, where the name starts with two &lt;a href=&quot;https://realpython.com/python-double-underscore/&quot;&gt;underscores&lt;/a&gt;, followed by an &lt;a href=&quot;/ref/glossary/identifier/&quot; class=&quot;ref-link&quot;&gt;identifier&lt;/a&gt; and ends with another pair of underscores.&lt;/p&gt;
&lt;p&gt;Essentially, each built-in function or operator has a special method corresponding to it. For example, there’s &lt;code&gt;__len__()&lt;/code&gt;, corresponding to &lt;code&gt;len()&lt;/code&gt;, and &lt;code&gt;__add__()&lt;/code&gt;, corresponding to the &lt;code&gt;+&lt;/code&gt; operator.&lt;/p&gt;
&lt;p&gt;By default, most of the built-ins and operators will not work with objects of your classes. You must add the corresponding special methods in your class definition to make your object compatible with built-ins and operators.&lt;/p&gt;
&lt;p&gt;When you do this, the behavior of the function or operator associated with it changes according to that defined in the method.&lt;/p&gt;
&lt;p&gt;This is exactly what the &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html&quot;&gt;Data Model&lt;/a&gt; (Section 3 of the Python documentation) helps you accomplish. It lists all the special methods available and provides you with the means of overloading built-in functions and operators so that you can use them on your own objects.&lt;/p&gt;
&lt;p&gt;Let’s see what this means.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Fun fact:&lt;/strong&gt; Due to the naming convention used for these methods, they are also called &lt;em&gt;dunder methods&lt;/em&gt; which is a shorthand for &lt;em&gt;&lt;strong&gt;d&lt;/strong&gt;ouble &lt;strong&gt;under&lt;/strong&gt;score methods&lt;/em&gt;. Sometimes they’re also referred to as &lt;em&gt;special methods&lt;/em&gt; or &lt;em&gt;magic methods&lt;/em&gt;. We prefer &lt;em&gt;dunder methods&lt;/em&gt; though!&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;the-internals-of-operations-like-len-and&quot;&gt;The Internals of Operations Like &lt;code&gt;len()&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#the-internals-of-operations-like-len-and&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every class in Python defines its own behavior for built-in functions and methods. When you pass an instance of some class to a built-in function or use an operator on the instance, it is actually equivalent to calling a special method with relevant &lt;a href=&quot;/ref/glossary/argument/&quot; class=&quot;ref-link&quot;&gt;arguments&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If there is a built-in function, &lt;code&gt;func()&lt;/code&gt;, and the corresponding special method for the function is &lt;code&gt;__func__()&lt;/code&gt;, Python interprets a call to the function as &lt;code&gt;obj.__func__()&lt;/code&gt;, where &lt;code&gt;obj&lt;/code&gt; is the object. In the case of operators, if you have an operator &lt;code&gt;opr&lt;/code&gt; and the corresponding special method for it is &lt;code&gt;__opr__()&lt;/code&gt;, Python interprets something like &lt;code&gt;obj1 &amp;lt;opr&amp;gt; obj2&lt;/code&gt; as &lt;code&gt;obj1.__opr__(obj2)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So, when you’re calling &lt;code&gt;len()&lt;/code&gt; on an object, Python handles the call as &lt;code&gt;obj.__len__()&lt;/code&gt;. When you use the &lt;code&gt;[]&lt;/code&gt; operator on an &lt;a href=&quot;/ref/glossary/iterable/&quot; class=&quot;ref-link&quot;&gt;iterable&lt;/a&gt; to obtain the value at an index, Python handles it as &lt;code&gt;itr.__getitem__(index)&lt;/code&gt;, where &lt;code&gt;itr&lt;/code&gt; is the iterable object and &lt;code&gt;index&lt;/code&gt; is the index you want to obtain.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/operator-function-overloading/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/operator-function-overloading/ »&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>Documenting Python Code: A Complete Guide</title>
      <id>https://realpython.com/documenting-python-code/</id>
      <link href="https://realpython.com/documenting-python-code/"/>
      <updated>2026-11-01T14:00:00+00:00</updated>
      <summary>A complete guide to documenting Python code. Whether you&#x27;re documenting a small script or a large project, this guide covers what you need to know.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Welcome to your complete guide to documenting Python code. Whether you’re documenting a small &lt;a href=&quot;/ref/computer-science-glossary/script/&quot; class=&quot;ref-link&quot;&gt;script&lt;/a&gt; or a large project, whether you’re a &lt;a href=&quot;https://realpython.com/python-beginner-tips/&quot;&gt;beginner&lt;/a&gt; or a seasoned Pythonista, this guide will cover everything you need to know.&lt;/p&gt;
&lt;p&gt;We’ve broken up this tutorial into four major sections:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;#why-documenting-your-code-is-so-important&quot;&gt;Why Documenting Your Code Is So Important&lt;/a&gt;:&lt;/strong&gt; An introduction to documentation and its importance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;#commenting-vs-documenting-code&quot;&gt;Commenting vs Documenting Code&lt;/a&gt;:&lt;/strong&gt; An overview of the major differences between commenting and documenting, as well as the appropriate times and ways to use commenting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;#documenting-your-python-code-base-using-docstrings&quot;&gt;Documenting Your Python Code Base Using Docstrings&lt;/a&gt;:&lt;/strong&gt; A deep dive into docstrings for classes, class methods, functions, &lt;a href=&quot;/ref/glossary/module/&quot; class=&quot;ref-link&quot;&gt;modules&lt;/a&gt;, &lt;a href=&quot;/ref/glossary/package/&quot; class=&quot;ref-link&quot;&gt;packages&lt;/a&gt;, and scripts, as well as what should be found within each one&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;#documenting-your-python-projects&quot;&gt;Documenting Your Python Projects&lt;/a&gt;:&lt;/strong&gt; The necessary elements and what they should contain for your Python projects&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Feel free to read through this tutorial from beginning to end or jump to a section you’re interested in. It was designed to work both ways.&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.ef3487c363c6.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 “Documenting Python Code: A Complete Guide” quiz. You’ll receive a score upon completion to help you track your learning progress:&lt;/p&gt;

  &lt;hr&gt;

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

      &lt;a href=&quot;/quizzes/documenting-python-code/&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;Documenting Python Code Guide&quot; src=&quot;https://files.realpython.com/media/Documenting-Python-Code_Watermarked.0b26408a1b7f.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Documenting-Python-Code_Watermarked.0b26408a1b7f.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Documenting-Python-Code_Watermarked.0b26408a1b7f.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Documenting-Python-Code_Watermarked.0b26408a1b7f.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Documenting-Python-Code_Watermarked.0b26408a1b7f.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.ef3487c363c6.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/documenting-python-code/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Documenting Python Code: A Complete Guide&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 documenting Python code. With this knowledge, you&#x27;ll be able to effectively document your Python scripts and projects, making them more understandable and maintainable.&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/documenting-python-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-documenting-python-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to document your Python code with comments and docstrings.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Intermediate Python Deep Dive Live Course:&lt;/strong&gt; Want feedback on the code behind your docstrings? In Real Python’s &lt;a href=&quot;https://realpython.com/workshops/intermediate-deep-dive/&quot;&gt;Intermediate Python Deep Dive&lt;/a&gt; live course, you work on Pythonic design and clean, maintainable code with an instructor and a small cohort. Join the waitlist to hear about the next dates.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;why-documenting-your-code-is-so-important&quot;&gt;Why Documenting Your Code Is So Important&lt;a class=&quot;headerlink&quot; href=&quot;#why-documenting-your-code-is-so-important&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Hopefully, if you’re reading this tutorial, you already know the importance of documenting your code. But if not, then let me quote something Guido mentioned to me at a recent &lt;a href=&quot;https://realpython.com/pycon-guide/&quot;&gt;PyCon&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Code is more often read than written.”&lt;/p&gt;
&lt;p&gt;— &lt;em&gt;&lt;a href=&quot;/ref/glossary/guido-van-rossum/&quot; class=&quot;ref-link&quot;&gt;Guido van Rossum&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When you write code, you write it for two primary audiences: your users and your developers (including yourself). Both audiences are equally important. If you’re like me, you’ve probably opened up old codebases and wondered to yourself, “What in the world was I thinking?” If you’re having a problem reading your own code, imagine what your users or other developers are experiencing when they’re trying to use or &lt;a href=&quot;https://realpython.com/start-contributing-python/&quot;&gt;contribute&lt;/a&gt; to your code.&lt;/p&gt;
&lt;p&gt;Conversely, I’m sure you’ve run into a situation where you wanted to do something in Python and found what looks like a great library that can get the job done. However, when you start using the library, you look for examples, write-ups, or even official documentation on how to do something specific and can’t immediately find the solution.&lt;/p&gt;
&lt;p&gt;After searching, you come to realize that the documentation is lacking or even worse, missing entirely. This is a frustrating feeling that deters you from using the library, no matter how great or efficient the code is. Daniele Procida summarized this situation best:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“It doesn’t matter how good your software is, because &lt;strong&gt;if the documentation is not good enough, people will not use it.&lt;/strong&gt;“&lt;/p&gt;
&lt;p&gt;— &lt;em&gt;&lt;a href=&quot;https://docs.divio.com/documentation-system/&quot;&gt;Daniele Procida&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this guide, you’ll learn from the ground up how to properly document your Python code from the smallest of scripts to the largest of &lt;a href=&quot;https://realpython.com/intermediate-python-project-ideas/&quot;&gt;Python projects&lt;/a&gt; to help prevent your users from ever feeling too frustrated to use or contribute to your project.&lt;/p&gt;
&lt;h2 id=&quot;commenting-vs-documenting-code&quot;&gt;Commenting vs Documenting Code&lt;a class=&quot;headerlink&quot; href=&quot;#commenting-vs-documenting-code&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before we can go into how to document your Python code, we need to distinguish documenting from commenting.&lt;/p&gt;
&lt;p&gt;In general, commenting is describing your code to/for developers. The intended main audience is the maintainers and developers of the Python code. In conjunction with well-written code, comments help to guide the reader to better understand your code and its purpose and design:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Code tells you how; Comments tell you why.”&lt;/p&gt;
&lt;p&gt;— &lt;em&gt;&lt;a href=&quot;https://blog.codinghorror.com/code-tells-you-how-comments-tell-you-why/&quot;&gt;Jeff Atwood&lt;/a&gt; (aka Coding Horror)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Documenting code is describing its use and functionality to your users. While it may be helpful in the development process, the main intended audience is the users. The following section describes how and when to comment your code.&lt;/p&gt;
&lt;h3 id=&quot;basics-of-commenting-code&quot;&gt;Basics of Commenting Code&lt;a class=&quot;headerlink&quot; href=&quot;#basics-of-commenting-code&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Comments are created in Python using the pound sign (&lt;code&gt;#&lt;/code&gt;) and should be brief statements no longer than a few sentences. Here’s a simple example:&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;hello_world&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# A simple comment preceding a simple print statement&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;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.ef3487c363c6.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;According to &lt;a href=&quot;https://pep8.org/#maximum-line-length&quot;&gt;PEP 8&lt;/a&gt;, comments should have a maximum length of 72 characters. This is true even if your project changes the max line length to be greater than the recommended 80 characters. If a comment is going to be greater than the comment char limit, using multiple lines for the comment is appropriate:&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;hello_long_world&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# A very long statement that just goes on and on and on and on and&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# never ends until after it&#x27;s reached the 80 char limit&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;Hellooooooooooooooooooooooooooooooooooooooooooooooooooooooo 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.ef3487c363c6.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/documenting-python-code/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/documenting-python-code/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>Recursion in Python: An Introduction</title>
      <id>https://realpython.com/python-recursion/</id>
      <link href="https://realpython.com/python-recursion/"/>
      <updated>2026-11-01T14:00:00+00:00</updated>
      <summary>Get to grips with Python recursion: what it is, how it works, when to reach for it, and how recursive and iterative solutions compare.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’re familiar with &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions in Python&lt;/a&gt;, then you know that it’s quite common for one function to call another. In Python, it’s also possible for a function to call itself!  A function that calls itself is said to be &lt;strong&gt;recursive&lt;/strong&gt;, and the technique of employing a recursive function is called &lt;strong&gt;recursion&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It may seem peculiar for a function to call itself, but many types of programming problems are best expressed recursively. When you bump up against such a problem, recursion is an indispensable tool for you to have in your toolkit.&lt;/p&gt;
&lt;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.ef3487c363c6.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 “Recursion in Python: 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-recursion/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #ff7e74;&quot; alt=&quot;Recursion in Python: An Introduction&quot; src=&quot;https://files.realpython.com/media/TUT20-Recursion-in-Python_Watermarked.692052217920.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/TUT20-Recursion-in-Python_Watermarked.692052217920.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/TUT20-Recursion-in-Python_Watermarked.692052217920.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/TUT20-Recursion-in-Python_Watermarked.692052217920.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/TUT20-Recursion-in-Python_Watermarked.692052217920.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.ef3487c363c6.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-recursion/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Recursion in Python: An Introduction&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of recursion in Python, including base cases, recursive structure, performance considerations, and common use cases.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What it means for a function to call itself &lt;strong&gt;recursively&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How the &lt;strong&gt;design&lt;/strong&gt; of Python functions supports recursion&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;factors&lt;/strong&gt; to consider when choosing whether or not to solve a problem recursively&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;implement&lt;/strong&gt; a recursive function in Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then you’ll study several Python programming problems that use recursion and contrast the recursive solution with a comparable non-recursive one.&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-recursion-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-recursion-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to solve problems with recursive functions in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;what-is-recursion&quot;&gt;What Is Recursion?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-recursion&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The word &lt;strong&gt;recursion&lt;/strong&gt; comes from the Latin word &lt;em&gt;recurrere&lt;/em&gt;, meaning to run or hasten back, return, revert, or recur. Here are some online definitions of recursion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.dictionary.com/browse/recursion&quot;&gt;&lt;strong&gt;Dictionary.com&lt;/strong&gt;:&lt;/a&gt; The act or process of returning or running back&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://en.wiktionary.org/wiki/recursion&quot;&gt;&lt;strong&gt;Wiktionary&lt;/strong&gt;:&lt;/a&gt; The act of defining an object (usually a function) in terms of that object itself&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.thefreedictionary.com/recursion&quot;&gt;&lt;strong&gt;The Free Dictionary&lt;/strong&gt;:&lt;/a&gt; A method of defining a sequence of objects, such as an expression, function, or set, where some number of initial objects are given and each successive object is defined in terms of the preceding objects&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A &lt;strong&gt;recursive&lt;/strong&gt; definition is one in which the defined term appears in the definition itself. Self-referential situations often crop up in real life, even if they aren’t immediately recognizable as such. For example, suppose you wanted to describe the set of people that make up your ancestors. You could describe them this way:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/jsturtz-ancestors.9f0adeb014ef.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block dark-white-plate w-66&quot; src=&quot;https://files.realpython.com/media/jsturtz-ancestors.9f0adeb014ef.png&quot; width=&quot;1263&quot; height=&quot;63&quot; srcset=&quot;/cdn-cgi/image/width=315,format=auto/https://files.realpython.com/media/jsturtz-ancestors.9f0adeb014ef.png 315w, /cdn-cgi/image/width=421,format=auto/https://files.realpython.com/media/jsturtz-ancestors.9f0adeb014ef.png 421w, /cdn-cgi/image/width=631,format=auto/https://files.realpython.com/media/jsturtz-ancestors.9f0adeb014ef.png 631w, /cdn-cgi/image/width=1263,format=auto/https://files.realpython.com/media/jsturtz-ancestors.9f0adeb014ef.png 1263w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Recursive definition of ancestors&quot; data-asset=&quot;3520&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Notice how the concept that is being defined, &lt;strong&gt;ancestors&lt;/strong&gt;, shows up in its own definition. This is a recursive definition.&lt;/p&gt;
&lt;p&gt;In programming, recursion has a very precise meaning. It refers to a coding technique in which a function calls itself.&lt;/p&gt;
&lt;h2 id=&quot;why-use-recursion&quot;&gt;Why Use Recursion?&lt;a class=&quot;headerlink&quot; href=&quot;#why-use-recursion&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Most programming problems are solvable without recursion. So, strictly speaking, recursion usually isn’t necessary.&lt;/p&gt;
&lt;p&gt;However, some situations particularly lend themselves to a &lt;strong&gt;self-referential&lt;/strong&gt; definition—for example, the definition of ancestors shown above. If you were devising an &lt;a href=&quot;/ref/computer-science-glossary/algorithm/&quot; class=&quot;ref-link&quot;&gt;algorithm&lt;/a&gt; to handle such a case programmatically, a recursive solution would likely be cleaner and more concise.&lt;/p&gt;
&lt;p&gt;Traversal of &lt;a href=&quot;https://en.wikipedia.org/wiki/Tree_(data_structure)&quot;&gt;tree-like data structures&lt;/a&gt; is another good example. Because these are nested structures, they readily fit a recursive definition. A non-recursive algorithm to walk through a nested structure is likely to be somewhat clunky, while a recursive solution will be relatively elegant. An example of this appears later in this tutorial.&lt;/p&gt;
&lt;p&gt;On the other hand, recursion isn’t for every situation. Here are some other factors to consider:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For some problems, a recursive solution, though possible, will be awkward rather than elegant.&lt;/li&gt;
&lt;li&gt;Recursive implementations often consume more memory than non-recursive ones.&lt;/li&gt;
&lt;li&gt;In some cases, using recursion may result in slower execution time.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Typically, the readability of the code will be the biggest determining factor. But it depends on the circumstances. The examples presented below should help you get a feel for when you should choose recursion.&lt;/p&gt;
&lt;h2 id=&quot;recursion-in-python&quot;&gt;Recursion in Python&lt;a class=&quot;headerlink&quot; href=&quot;#recursion-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you call a function in Python, the &lt;a href=&quot;/ref/glossary/interpreter/&quot; class=&quot;ref-link&quot;&gt;interpreter&lt;/a&gt; creates a new &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;local namespace&lt;/a&gt; so that names defined within that function don’t &lt;a href=&quot;https://en.wikipedia.org/wiki/Name_collision&quot;&gt;collide&lt;/a&gt; with identical names defined elsewhere. One function can call another, and even if they both define objects with the same name, it all works out fine because those objects exist in separate &lt;strong&gt;namespaces&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The same holds true if multiple instances of the same function are running concurrently. For example, consider the following definition:&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;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/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.ef3487c363c6.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-recursion/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-recursion/ »&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: Documenting Python Code: A Complete Guide</title>
      <id>https://realpython.com/quizzes/documenting-python-code/</id>
      <link href="https://realpython.com/quizzes/documenting-python-code/"/>
      <updated>2026-11-01T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of documenting Python code. With this knowledge, you&#x27;ll be able to effectively document your Python scripts and projects, making them more understandable and maintainable.</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/documenting-python-code/&quot;&gt;Documenting Python Code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This tutorial covers the importance of documentation, the differences between commenting and documenting, the use of docstrings, and the necessary elements for documenting your Python projects.&lt;/p&gt;
&lt;p&gt;With this knowledge, you&amp;rsquo;ll be able to effectively document your Python scripts and projects, making them more understandable and maintainable.&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 Python zip() Function for Parallel Iteration</title>
      <id>https://realpython.com/python-zip-function/</id>
      <link href="https://realpython.com/python-zip-function/"/>
      <updated>2026-10-31T14:00:00+00:00</updated>
      <summary>Learn how to use the Python zip() function to iterate over multiple iterables in parallel, unzip sequences, and build dictionaries with less code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s &lt;code&gt;zip()&lt;/code&gt; function combines elements from multiple &lt;a href=&quot;/ref/glossary/iterable/&quot; class=&quot;ref-link&quot;&gt;iterables&lt;/a&gt;. Calling &lt;code&gt;zip()&lt;/code&gt; generates an &lt;a href=&quot;/ref/glossary/iterator/&quot; class=&quot;ref-link&quot;&gt;iterator&lt;/a&gt; that yields tuples, each containing elements from the input iterables. This function is essential for tasks like parallel iteration and &lt;a href=&quot;/ref/glossary/dictionary/&quot; class=&quot;ref-link&quot;&gt;dictionary&lt;/a&gt; creation, offering an efficient way to handle multiple &lt;a href=&quot;/ref/glossary/sequence/&quot; class=&quot;ref-link&quot;&gt;sequences&lt;/a&gt; in Python programming.&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;code&gt;zip()&lt;/code&gt; in Python aggregates elements from multiple iterables into tuples, facilitating &lt;strong&gt;parallel iteration&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dict(zip())&lt;/code&gt; &lt;strong&gt;creates dictionaries&lt;/strong&gt; by pairing keys and values from two sequences.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zip()&lt;/code&gt; is &lt;strong&gt;lazy&lt;/strong&gt; in Python, meaning it returns an iterator instead of a list.&lt;/li&gt;
&lt;li&gt;There’s no &lt;code&gt;unzip()&lt;/code&gt; function in Python, but the same &lt;code&gt;zip()&lt;/code&gt; function can &lt;strong&gt;reverse the process&lt;/strong&gt; using the &lt;a href=&quot;/ref/glossary/unpacking/&quot; class=&quot;ref-link&quot;&gt;unpacking&lt;/a&gt; operator &lt;code&gt;*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Alternatives to &lt;code&gt;zip()&lt;/code&gt; include &lt;code&gt;itertools.zip_longest()&lt;/code&gt; for handling iterables of &lt;strong&gt;unequal lengths&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, you’ll explore how to use &lt;code&gt;zip()&lt;/code&gt; for parallel iteration. You’ll also learn how to handle iterables of unequal lengths and discover the convenience of using &lt;code&gt;zip()&lt;/code&gt; with dictionaries. Whether you’re working with lists, tuples, or other data structures, understanding &lt;code&gt;zip()&lt;/code&gt; will enhance your coding skills and streamline your Python projects.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-mastery-course/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-mastery-course&quot; markdown&gt;5 Thoughts On Python Mastery&lt;/a&gt;, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.&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.ef3487c363c6.svg#@quiz&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt; Take the Quiz:&lt;/strong&gt;&lt;/mark&gt; Test your knowledge with our interactive “Using the Python zip() Function for Parallel Iteration” 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-zip-function/&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;Using the Python zip() Function for Parallel Iteration&quot; src=&quot;https://files.realpython.com/media/How-to-Use-Python-Zip-with-Examples_Watermarked.3020903367b6.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/How-to-Use-Python-Zip-with-Examples_Watermarked.3020903367b6.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Use-Python-Zip-with-Examples_Watermarked.3020903367b6.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Use-Python-Zip-with-Examples_Watermarked.3020903367b6.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Use-Python-Zip-with-Examples_Watermarked.3020903367b6.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.ef3487c363c6.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-zip-function/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Using the Python zip() Function for Parallel Iteration&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Check your understanding of Python&#x27;s zip() function for parallel iteration, unzipping sequences, and building dictionaries from two lists.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;understanding-the-python-zip-function&quot;&gt;Understanding the Python &lt;code&gt;zip()&lt;/code&gt; Function&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-the-python-zip-function&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;zip()&lt;/code&gt; is available in the &lt;a href=&quot;https://docs.python.org/3/library/builtins.html&quot;&gt;built-in namespace&lt;/a&gt;. If you use &lt;code&gt;dir()&lt;/code&gt; to inspect &lt;code&gt;__builtins__&lt;/code&gt;, then you’ll see &lt;code&gt;zip()&lt;/code&gt; at the end of the list:&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.ef3487c363c6.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;dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__builtins__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&#x27;ArithmeticError&#x27;, &#x27;AssertionError&#x27;, &#x27;AttributeError&#x27;, ..., &#x27;zip&#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.ef3487c363c6.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 see that &lt;code&gt;&#x27;zip&#x27;&lt;/code&gt; is the last entry in the list of available objects.&lt;/p&gt;
&lt;p&gt;According to the &lt;a href=&quot;https://docs.python.org/3/builtins/functions.html#zip&quot;&gt;official documentation&lt;/a&gt;, Python’s &lt;code&gt;zip()&lt;/code&gt; function behaves as follows:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Iterate over several iterables in parallel, producing tuples with an item from each one. […] More formally: &lt;code&gt;zip()&lt;/code&gt; returns an iterator of tuples, where the &lt;em&gt;i&lt;/em&gt;-th tuple contains the &lt;em&gt;i&lt;/em&gt;-th element from each of the argument iterables. […]&lt;/p&gt;
&lt;p&gt;By default, &lt;code&gt;zip()&lt;/code&gt; stops when the shortest iterable is exhausted. […] With a single iterable argument, &lt;code&gt;zip()&lt;/code&gt; returns an iterator of 1-tuples. With no arguments, it returns an empty iterator. (&lt;a href=&quot;https://docs.python.org/3/builtins/functions.html#zip&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You’ll unpack this definition throughout the rest of the tutorial. As you work through the code examples, you’ll see that Python zip operations work just like the physical zipper on a bag or pair of jeans. Interlocking pairs of teeth on both sides of the zipper are pulled together to close an opening. In fact, this visual analogy is perfect for understanding &lt;code&gt;zip()&lt;/code&gt;, since the function was named after physical zippers!&lt;/p&gt;
&lt;h2 id=&quot;using-zip-in-python&quot;&gt;Using &lt;code&gt;zip()&lt;/code&gt; in Python&lt;a class=&quot;headerlink&quot; href=&quot;#using-zip-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The signature of Python’s &lt;code&gt;zip()&lt;/code&gt; function is &lt;code&gt;zip(*iterables, strict=False)&lt;/code&gt;. You’ll learn more about &lt;code&gt;strict&lt;/code&gt; later. The function takes in &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-iterable&quot;&gt;iterables&lt;/a&gt; as arguments and returns an &lt;strong&gt;iterator&lt;/strong&gt;. This iterator generates a series of tuples containing elements from each iterable. &lt;code&gt;zip()&lt;/code&gt; can accept any type of iterable, such as &lt;a href=&quot;https://realpython.com/read-write-files-python/&quot;&gt;files&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;lists, tuples&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;sets&lt;/a&gt;, and so on.&lt;/p&gt;
&lt;h3 id=&quot;passing-n-arguments&quot;&gt;Passing &lt;code&gt;n&lt;/code&gt; Arguments&lt;a class=&quot;headerlink&quot; href=&quot;#passing-n-arguments&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you use &lt;code&gt;zip()&lt;/code&gt; with &lt;code&gt;n&lt;/code&gt; arguments, then the function will return an iterator that generates tuples of length &lt;code&gt;n&lt;/code&gt;. To see this in action, take a look at the following code block:&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.ef3487c363c6.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;numbers&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;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;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;letters&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;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zipped&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&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;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;letters&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;zipped&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Holds an iterator object&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;zip object at 0x7fa4831153c8&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;nb&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zipped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;class &#x27;zip&#x27;&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;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zipped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[(1, &#x27;a&#x27;), (2, &#x27;b&#x27;), (3, &#x27;c&#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.ef3487c363c6.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 use &lt;code&gt;zip(numbers, letters)&lt;/code&gt; to create an iterator that produces tuples of the form &lt;code&gt;(x, y)&lt;/code&gt;. In this case, the &lt;code&gt;x&lt;/code&gt; values are taken from &lt;code&gt;numbers&lt;/code&gt; and the &lt;code&gt;y&lt;/code&gt; values are taken from &lt;code&gt;letters&lt;/code&gt;. Notice how the Python &lt;code&gt;zip()&lt;/code&gt; function returns an iterator. To retrieve the final list object, you need to use &lt;code&gt;list()&lt;/code&gt; to consume the iterator.&lt;/p&gt;
&lt;p&gt;If you’re working with sequences like lists, tuples, or &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, then your iterables are guaranteed to be evaluated from left to right. This means that the resulting list of tuples will take the form &lt;code&gt;[(numbers[0], letters[0]), (numbers[1], letters[1]),..., (numbers[n], letters[n])]&lt;/code&gt;. However, for other types of iterables (like &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;sets&lt;/a&gt;), you might see some weird results:&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.ef3487c363c6.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;s1&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;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;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;s2&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;b&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&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;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[(1, &#x27;a&#x27;), (2, &#x27;c&#x27;), (3, &#x27;b&#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.ef3487c363c6.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;s1&lt;/code&gt; and &lt;code&gt;s2&lt;/code&gt; are &lt;code&gt;set&lt;/code&gt; objects, which don’t keep their elements in any particular order. This means that the tuples returned by &lt;code&gt;zip()&lt;/code&gt; will have elements that are paired up randomly. If you’re going to use the Python &lt;code&gt;zip()&lt;/code&gt; function with unordered iterables like sets, then this is something to keep in mind.&lt;/p&gt;
&lt;h3 id=&quot;passing-no-arguments&quot;&gt;Passing No Arguments&lt;a class=&quot;headerlink&quot; href=&quot;#passing-no-arguments&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can call &lt;code&gt;zip()&lt;/code&gt; with no arguments as well. In this case, you’ll simply get an empty iterator:&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.ef3487c363c6.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;zipped&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&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;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zipped&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;zip object at 0x7f196294a488&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;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zipped&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; 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.ef3487c363c6.svg#@copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/button&gt;
    
  &lt;/div&gt;
&lt;/code-block&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-zip-function/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-zip-function/ »&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>Object-Oriented Programming in Python vs Java</title>
      <id>https://realpython.com/oop-in-python-vs-java/</id>
      <link href="https://realpython.com/oop-in-python-vs-java/"/>
      <updated>2026-10-31T14:00:00+00:00</updated>
      <summary>Compare Python vs Java for object-oriented programming and learn how to apply your Java knowledge of classes and objects to Python in a Pythonic way.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Java programmers making a move to Python often struggle with Python’s approach to object-oriented programming (OOP). The approach to working with objects, variable types, and other language capabilities taken by Python vs Java are quite different. It can make switching between both languages very confusing.&lt;/p&gt;
&lt;p&gt;This article compares and contrasts object-oriented programming support in Python vs Java. By the end, you’ll be able to apply your knowledge of object-oriented programming to Python, understand how to reinterpret your understanding of Java objects to Python, and use objects in a &lt;a href=&quot;/ref/glossary/pythonic/&quot; class=&quot;ref-link&quot;&gt;Pythonic&lt;/a&gt; way.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Over the course of this article, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Build a basic class in both Java and Python&lt;/li&gt;
&lt;li&gt;Explore how object attributes work in Python vs Java&lt;/li&gt;
&lt;li&gt;Compare and contrast Java methods and Python functions&lt;/li&gt;
&lt;li&gt;Discover inheritance and polymorphism mechanisms in both languages&lt;/li&gt;
&lt;li&gt;Investigate reflection across Python vs Java&lt;/li&gt;
&lt;li&gt;Apply everything in a complete class implementation in both languages&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This article isn’t a primer on object-oriented programming. Rather, it compares object-oriented features and principles of Python vs Java. Readers should have good knowledge of Java, and also be familiar with coding Python. If you are unfamiliar with object-oriented programming, then check out &lt;a href=&quot;https://realpython.com/courses/intro-object-oriented-programming-oop-python/&quot;&gt;Intro to Object-Oriented Programming (OOP) in Python&lt;/a&gt;. All Python examples will work with Python 3.6 or later.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Download Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/oop-python-vs-java/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-oop-python-vs-java&quot; markdown&gt;Click here to download the free source code&lt;/a&gt; for the Java and Python objects in this article.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Object-Oriented Python Live Course:&lt;/strong&gt; Want to design classes the Pythonic way? In Real Python’s &lt;a href=&quot;https://realpython.com/workshops/python-oop/&quot;&gt;Object-Oriented Python&lt;/a&gt; live course, you build a complete project with an instructor, from Python’s data model to choosing between inheritance and composition. Join the waitlist to hear about the next dates.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;sample-classes-in-python-vs-java&quot;&gt;Sample Classes in Python vs Java&lt;a class=&quot;headerlink&quot; href=&quot;#sample-classes-in-python-vs-java&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To begin, you’ll implement the same small &lt;a href=&quot;https://realpython.com/python-classes/&quot;&gt;class&lt;/a&gt; in both Python and Java to illustrate the differences between them. You’ll make modifications to them as the article progresses.&lt;/p&gt;
&lt;p&gt;First, assume you have the following &lt;code&gt;Car&lt;/code&gt; class definition in Java:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;java&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--purple&quot;&gt;
    &lt;span class=&quot;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Java&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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Car&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &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;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&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;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Car&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&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;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&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;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&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;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;year&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&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;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;11&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;getColor&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;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;15&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;getModel&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;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;19&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;getYear&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;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;23&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.ef3487c363c6.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;Java classes are defined in files with the same name as the class. So, you have to save this class in a file named &lt;code&gt;Car.java&lt;/code&gt;. Only one public top-level class can be defined in each file.&lt;/p&gt;
&lt;p&gt;A similar small &lt;code&gt;Car&lt;/code&gt; class is written in Python as follows:&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;linenos&quot;&gt; 1&lt;/span&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;Car&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;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;fm&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;year&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;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;year&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.ef3487c363c6.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 Python you can declare a class anywhere, in any file, at any time. Save this class in the file &lt;code&gt;car.py&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Using these classes as your base, you can explore the basic components of classes and objects.&lt;/p&gt;
&lt;h2 id=&quot;object-attributes&quot;&gt;Object Attributes&lt;a class=&quot;headerlink&quot; href=&quot;#object-attributes&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;All object-oriented languages have some way to store data about the object. In Java and Python, data is stored in &lt;strong&gt;attributes&lt;/strong&gt;, which are variables associated with specific objects.&lt;/p&gt;
&lt;p&gt;One of the most significant differences between Python vs Java is how they define and manage class and object attributes. Some of these differences come from constraints imposed by the languages, while others come from best practices.&lt;/p&gt;
&lt;h3 id=&quot;declaration-and-initialization&quot;&gt;Declaration and Initialization&lt;a class=&quot;headerlink&quot; href=&quot;#declaration-and-initialization&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Java, you declare attributes in the class body, outside of any methods, with a definite type. You must define class attributes before they are used:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;java&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--purple&quot;&gt;
    &lt;span class=&quot;me-2 noselect&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Language: &lt;/span&gt;Java&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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Car&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&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.ef3487c363c6.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 Python, you both declare and define attributes inside the class &lt;code&gt;__init__()&lt;/code&gt;, which is the equivalent of Java’s constructor:&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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;fm&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;year&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;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;    &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;    &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;year&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.ef3487c363c6.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;By prefixing the variable names with &lt;code&gt;self&lt;/code&gt;, you tell Python these are attributes. Each &lt;a href=&quot;/ref/glossary/instance/&quot; class=&quot;ref-link&quot;&gt;instance&lt;/a&gt; of the class will have a copy. All variables in Python are &lt;a href=&quot;https://realpython.com/python-type-checking/#duck-typing&quot;&gt;loosely typed&lt;/a&gt;, and these attributes are no exception.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/oop-in-python-vs-java/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/oop-in-python-vs-java/ »&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>OpenAI Halves the Price of Its New Everyday AI Model</title>
      <id>https://realpython.com/ai-news-weekly-2026-10-30/</id>
      <link href="https://realpython.com/ai-news-weekly-2026-10-30/"/>
      <updated>2026-10-31T14:00:00+00:00</updated>
      <summary>Real Python&#x27;s weekly AI news for October 24–30, 2026, explained in plain language: Cheaper OpenAI Model, Free Mistral Model, and New Kimi Model.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;em&gt;Real Python AI News · Weekly edition · The week of October 24–30, 2026&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;card border rounded my-4&quot;&gt;&lt;div class=&quot;card-body&quot;&gt;&lt;div class=&quot;row align-items-center g-3&quot;&gt;&lt;div class=&quot;col-md-6&quot;&gt;&lt;figure class=&quot;&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid &quot; src=&quot;https://files.realpython.com/media/email.593b33f65c83.png&quot; width=&quot;2700&quot; height=&quot;2040&quot; srcset=&quot;/cdn-cgi/image/width=675,format=auto/https://files.realpython.com/media/email.593b33f65c83.png 675w, /cdn-cgi/image/width=900,format=auto/https://files.realpython.com/media/email.593b33f65c83.png 900w, /cdn-cgi/image/width=1350,format=auto/https://files.realpython.com/media/email.593b33f65c83.png 1350w, /cdn-cgi/image/width=2700,format=auto/https://files.realpython.com/media/email.593b33f65c83.png 2700w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;An email from Real Python titled Here Are Your AI News, What Changed and Why It Matters, with lavender newsletter artwork and a What&#x27;s New in AI heading.&quot; data-asset=&quot;7653&quot;&gt;&lt;/figure&gt;
&lt;/div&gt;&lt;div class=&quot;col-md-6&quot;&gt;&lt;p class=&quot;h4 mb-2&quot;&gt;Stop Falling Behind on AI. Catch Up in Five Minutes.&lt;/p&gt;&lt;p class=&quot;mb-3&quot;&gt;New models, new prices, new agent tools, all the time. Our new AI newsletter gives you the handful of stories you actually need as a developer. Free, straight from the Real Python team.&lt;/p&gt;


  &lt;div class=&quot;survey-form__modal&quot;&gt;




&lt;modal-button data-headline=&quot;Stop Falling Behind on AI. Catch Up in Five Minutes.&quot; data-no-footer=&quot;true&quot; data-large=&quot;true&quot; style=&quot;display:inline&quot;&gt;
  &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot; data-modal-trigger&gt;
    Get the free roundup
  &lt;/button&gt;
  &lt;template data-modal-content&gt;



&lt;survey-form class=&quot;survey-form d-block&quot; data-slug=&quot;ai-newsletter&quot; data-endpoint=&quot;/api/v1/surveys/ai-newsletter/submissions/&quot; data-draft-endpoint=&quot;/api/v1/surveys/ai-newsletter/draft/&quot; data-view-endpoint=&quot;/api/v1/surveys/ai-newsletter/view/&quot; data-pages=&quot;1&quot; data-definition-hash=&quot;48cf1caeda6e874d&quot; data-captcha=&quot;auto&quot; data-turnstile-sitekey=&quot;0x4AAAAAAAQQUCLRXBi8NnUh&quot; data-surface=&quot;modal&quot; data-authenticated=&quot;0&quot; data-save-progress=&quot;1&quot; data-preview=&quot;0&quot;&gt;
  &lt;template data-resume-notice&gt;
    &lt;div class=&quot;alert alert-light border d-flex justify-content-between align-items-center py-2 mb-4&quot; role=&quot;status&quot;&gt;
      &lt;span class=&quot;text-body-secondary&quot;&gt;&lt;span class=&quot;icon baseline me-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.ef3487c363c6.svg#solid--check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;We saved your progress from earlier.&lt;/span&gt;
      &lt;button type=&quot;button&quot; class=&quot;btn btn-link btn-sm p-0&quot; data-action=&quot;start-over&quot;&gt;Start over&lt;/button&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  &lt;div data-form-area&gt;

    &lt;form novalidate data-survey-form autocomplete=&quot;on&quot;&gt;
      &lt;div class=&quot;visually-hidden&quot; aria-hidden=&quot;true&quot;&gt;
        &lt;label for=&quot;ai-newsletter-hp&quot;&gt;Leave this field empty&lt;/label&gt;
        &lt;input type=&quot;text&quot; name=&quot;hp&quot; id=&quot;ai-newsletter-hp&quot; tabindex=&quot;-1&quot; autocomplete=&quot;off&quot;&gt;
      &lt;/div&gt;

        &lt;fieldset data-page=&quot;0&quot; data-next-label=&quot;Next&quot; tabindex=&quot;-1&quot;&gt;


              &lt;div class=&quot;survey-form__markdown article-body mb-4&quot;&gt;&lt;figure class=&quot;&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid rounded&quot; src=&quot;https://files.realpython.com/media/preview.4b4dadd03735.png&quot; width=&quot;2000&quot; height=&quot;834&quot; srcset=&quot;/cdn-cgi/image/width=500,format=auto/https://files.realpython.com/media/preview.4b4dadd03735.png 500w, /cdn-cgi/image/width=666,format=auto/https://files.realpython.com/media/preview.4b4dadd03735.png 666w, /cdn-cgi/image/width=1000,format=auto/https://files.realpython.com/media/preview.4b4dadd03735.png 1000w, /cdn-cgi/image/width=2000,format=auto/https://files.realpython.com/media/preview.4b4dadd03735.png 2000w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;An email from Real Python titled Here Are Your AI News, What Changed and Why It Matters, with lavender newsletter artwork and badges reading New issue in your inbox and In every issue.&quot; data-asset=&quot;7652&quot;&gt;&lt;/figure&gt;

&lt;p&gt;New models, new prices, new agent tools, all the time. Our new AI newsletter gives you the handful of stories you actually need as a developer.&lt;/p&gt;&lt;/div&gt;






&lt;div class=&quot;survey-form__field&quot; data-field=&quot;frequency&quot; data-field-type=&quot;checkbox&quot;&gt;

    &lt;fieldset data-required&gt;
      &lt;legend class=&quot;form-label fw-bold&quot;&gt;How often should it land in your inbox? Pick as many as you like.&lt;/legend&gt;


        &lt;div class=&quot;survey-form__pills&quot; data-pills&gt;

            &lt;span data-option data-value=&quot;daily&quot;&gt;
              &lt;input type=&quot;checkbox&quot; class=&quot;btn-check&quot; name=&quot;frequency&quot; id=&quot;survey-ai-newsletter-734c2b-frequency-daily&quot; value=&quot;daily&quot;&gt;
              &lt;label class=&quot;btn btn-outline-dark rounded-pill survey-form__pill&quot; for=&quot;survey-ai-newsletter-734c2b-frequency-daily&quot;&gt;☀️ Daily&lt;/label&gt;
            &lt;/span&gt;

            &lt;span data-option data-value=&quot;weekly&quot;&gt;
              &lt;input type=&quot;checkbox&quot; class=&quot;btn-check&quot; name=&quot;frequency&quot; id=&quot;survey-ai-newsletter-734c2b-frequency-weekly&quot; value=&quot;weekly&quot;&gt;
              &lt;label class=&quot;btn btn-outline-dark rounded-pill survey-form__pill&quot; for=&quot;survey-ai-newsletter-734c2b-frequency-weekly&quot;&gt;📬 Weekly&lt;/label&gt;
            &lt;/span&gt;

            &lt;span data-option data-value=&quot;monthly&quot;&gt;
              &lt;input type=&quot;checkbox&quot; class=&quot;btn-check&quot; name=&quot;frequency&quot; id=&quot;survey-ai-newsletter-734c2b-frequency-monthly&quot; value=&quot;monthly&quot;&gt;
              &lt;label class=&quot;btn btn-outline-dark rounded-pill survey-form__pill&quot; for=&quot;survey-ai-newsletter-734c2b-frequency-monthly&quot;&gt;🗓️ Monthly&lt;/label&gt;
            &lt;/span&gt;

        &lt;/div&gt;


    &lt;/fieldset&gt;

  &lt;div class=&quot;invalid-feedback d-block&quot; id=&quot;survey-ai-newsletter-734c2b-frequency-error&quot; data-error-for=&quot;frequency&quot; hidden&gt;&lt;/div&gt;
&lt;/div&gt;








&lt;div class=&quot;survey-form__field&quot; data-field=&quot;email&quot; data-field-type=&quot;email&quot;&gt;

    &lt;label class=&quot;form-label fw-bold&quot; for=&quot;survey-ai-newsletter-734c2b-email&quot;&gt;Your email address&lt;/label&gt;

    &lt;input type=&quot;email&quot; name=&quot;email&quot; class=&quot;form-control&quot; placeholder=&quot;you@example.com&quot; autocomplete=&quot;email&quot; maxlength=&quot;254&quot; id=&quot;survey-ai-newsletter-734c2b-email&quot; required&gt;

  &lt;div class=&quot;invalid-feedback d-block&quot; id=&quot;survey-ai-newsletter-734c2b-email-error&quot; data-error-for=&quot;email&quot; hidden&gt;&lt;/div&gt;
&lt;/div&gt;





              &lt;div class=&quot;survey-form__markdown article-body mb-4&quot;&gt;&lt;p&gt;&lt;strong&gt;Free, straight from the Real Python team. Unsubscribe anytime.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;






        &lt;/fieldset&gt;

      &lt;div class=&quot;alert alert-danger py-2&quot; data-form-error role=&quot;alert&quot; hidden&gt;&lt;/div&gt;
      &lt;div data-turnstile class=&quot;survey-form__turnstile&quot;&gt;&lt;/div&gt;
      &lt;div class=&quot;d-flex align-items-center flex-wrap gap-3 mt-4&quot;&gt;
        &lt;button type=&quot;button&quot; class=&quot;btn btn-link ps-0&quot; data-action=&quot;back&quot; hidden&gt;« Back&lt;/button&gt;
        &lt;button type=&quot;button&quot; class=&quot;btn btn-dark px-4&quot; data-action=&quot;next&quot; hidden&gt;Next&lt;/button&gt;
        &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary px-4&quot; data-action=&quot;submit&quot;&gt;Sign Me Up&lt;/button&gt;
        &lt;span class=&quot;small text-body-secondary&quot; data-saved-indicator hidden&gt;&lt;span class=&quot;icon baseline text-success me-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg aria-hidden=&quot;true&quot;&gt;&lt;use href=&quot;/static/icons.ef3487c363c6.svg#solid--check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;Saved&lt;/span&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  &lt;noscript&gt;
    &lt;div class=&quot;alert alert-warning mt-3&quot;&gt;This form needs JavaScript to work.&lt;/div&gt;
  &lt;/noscript&gt;
&lt;/survey-form&gt;

  &lt;/template&gt;
&lt;/modal-button&gt;

  &lt;/div&gt;

&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Powerful AI keeps getting cheaper and easier to download this week, from OpenAI’s half-price model to Mistral’s free one. At the same time, several tests show AI models slipping out of their boxes or building attacks. Here’s the week, explained in plain language.&lt;/p&gt;
&lt;h2 id=&quot;openai-cuts-the-cost-of-handing-office-chores-to-ai&quot;&gt;OpenAI Cuts the Cost of Handing Office Chores to AI&lt;a class=&quot;headerlink&quot; href=&quot;#openai-cuts-the-cost-of-handing-office-chores-to-ai&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/s-gpt-6-1-terra-framed.da7af9e550fd.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/s-gpt-6-1-terra-framed.da7af9e550fd.png&quot; width=&quot;2560&quot; height=&quot;1120&quot; srcset=&quot;/cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/s-gpt-6-1-terra-framed.da7af9e550fd.png 640w, /cdn-cgi/image/width=853,format=auto/https://files.realpython.com/media/s-gpt-6-1-terra-framed.da7af9e550fd.png 853w, /cdn-cgi/image/width=1280,format=auto/https://files.realpython.com/media/s-gpt-6-1-terra-framed.da7af9e550fd.png 1280w, /cdn-cgi/image/width=2560,format=auto/https://files.realpython.com/media/s-gpt-6-1-terra-framed.da7af9e550fd.png 2560w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Screenshot of the source page: Introducing GPT-6.1 Terra | OpenAI&quot; data-asset=&quot;7987&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Handing a dull office chore to AI pays off only when each run is cheap. OpenAI, maker of &lt;a href=&quot;/ref/ai-coding-tools/chatgpt/&quot; class=&quot;ref-link&quot;&gt;ChatGPT&lt;/a&gt;, now offers &lt;strong&gt;&lt;a href=&quot;https://openai.com/index/introducing-gpt-6-1-terra&quot;&gt;GPT-6.1 Terra&lt;/a&gt;&lt;/strong&gt;, a fast, lower-cost AI &lt;em&gt;model&lt;/em&gt; (the trained system behind an AI assistant). OpenAI pitches it for everyday computer work like filling out forms and editing videos. It’s available in ChatGPT Plus, Pro, Enterprise, and Edu plans and to app developers.&lt;/p&gt;
&lt;p&gt;Developers pay by the &lt;a href=&quot;/ref/ai-coding-glossary/token/&quot; class=&quot;ref-link&quot;&gt;token&lt;/a&gt;, a small piece of text that’s often part of a word. Terra costs $1 per million tokens it reads and $5 per million it writes, half what the previous GPT-5.6 Terra costs. On the coding test Terminal-Bench 4.0, OpenAI says it solves 50.3 percent of tasks, up from 21.5 percent. You can also see how it did on &lt;a href=&quot;https://realpython.com/ai-benchmark-gpt-6-1-terra/&quot;&gt;Real Python’s own AI benchmark&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On a test of &lt;em&gt;computer use&lt;/em&gt; (the AI clicking and typing its way through apps), OpenAI says it keeps pace with its top model, GPT-6 Astra, at a tenth of the price. Services offering many AI models list a limit of about 1.05 million tokens per request, with higher rates above 272,000.&lt;/p&gt;
&lt;div class=&quot;container bg-body-tertiary rounded border p-3 my-4&quot;&gt;
&lt;div class=&quot;row align-items-center&quot;&gt;
&lt;div class=&quot;col-3 col-md-2&quot;&gt;
&lt;figure class=&quot;&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid rounded-circle&quot; src=&quot;https://files.realpython.com/media/pacsany.19bcf16f5a00.jpg&quot; width=&quot;1920&quot; height=&quot;1920&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/pacsany.19bcf16f5a00.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/pacsany.19bcf16f5a00.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/pacsany.19bcf16f5a00.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/pacsany.19bcf16f5a00.jpg 1920w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Philipp Acsany&quot; data-asset=&quot;3678&quot;&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;div class=&quot;col&quot;&gt;
&lt;p class=&quot;mb-2&quot;&gt;“Price now matters as much as raw ability in the AI race, and a cheap model that’s good enough can make it practical to hand repetitive paperwork to software. OpenAI says its pricier models remain the better pick for the hardest coding jobs, and all the test results so far are its own.”&lt;/p&gt;
&lt;p class=&quot;small mb-0&quot;&gt;&lt;strong&gt;— Philipp Acsany&lt;/strong&gt;, Real Python&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&quot;mistrals-biggest-ai-model-is-now-free-to-download&quot;&gt;Mistral’s Biggest AI Model Is Now Free to Download&lt;a class=&quot;headerlink&quot; href=&quot;#mistrals-biggest-ai-model-is-now-free-to-download&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/s-mistral-large-4-open-weights-framed.afae32f77ff3.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/s-mistral-large-4-open-weights-framed.afae32f77ff3.png&quot; width=&quot;2560&quot; height=&quot;1120&quot; srcset=&quot;/cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/s-mistral-large-4-open-weights-framed.afae32f77ff3.png 640w, /cdn-cgi/image/width=853,format=auto/https://files.realpython.com/media/s-mistral-large-4-open-weights-framed.afae32f77ff3.png 853w, /cdn-cgi/image/width=1280,format=auto/https://files.realpython.com/media/s-mistral-large-4-open-weights-framed.afae32f77ff3.png 1280w, /cdn-cgi/image/width=2560,format=auto/https://files.realpython.com/media/s-mistral-large-4-open-weights-framed.afae32f77ff3.png 2560w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Screenshot of the source page: Mistral Large 4 (Le Chonk) is now open weight | Mistral&quot; data-asset=&quot;8013&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Anyone can now download Mistral Large 4, nicknamed &lt;a href=&quot;https://mistral.ai/news/mistral-large-4-oss/&quot;&gt;Le Chonk&lt;/a&gt;, the flagship AI model from the French company Mistral. The company publishes the model’s &lt;a href=&quot;/ref/ai-coding-glossary/weight/&quot; class=&quot;ref-link&quot;&gt;weights&lt;/a&gt;: the numbers a model learns during &lt;a href=&quot;/ref/ai-coding-glossary/training/&quot; class=&quot;ref-link&quot;&gt;training&lt;/a&gt;. With them, people can run the model on their own computers and adapt it. This improved version follows a public preview earlier in October and about three more weeks of training.&lt;/p&gt;
&lt;p&gt;The model has 1 trillion &lt;a href=&quot;/ref/ai-coding-glossary/parameter/&quot; class=&quot;ref-link&quot;&gt;parameters&lt;/a&gt;, another word for those learned numbers. It’s &lt;em&gt;multimodal&lt;/em&gt;, so it understands images as well as text, and Mistral says it handles more than 160 languages. On a coding test from Cognition, a maker of AI coding tools, Mistral reports a leading score of 19.7 percent, compared only with other downloadable models.&lt;/p&gt;
&lt;p&gt;The license allows free use, modification, and development of products built on the model. Only businesses selling the model as an online service need a separate license. Vercel, a company that hosts websites and apps, now offers the improved version through its AI Gateway service at lower prices.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/ai-news-weekly-2026-10-30/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ai-news-weekly-2026-10-30/ »&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>Generating Random Data in Python (Guide)</title>
      <id>https://realpython.com/python-random/</id>
      <link href="https://realpython.com/python-random/"/>
      <updated>2026-10-31T14:00:00+00:00</updated>
      <summary>Compare the Python random module with its alternatives for generating random data, on security, versatility, purpose, and speed.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;How random is random?  This is a weird question to ask, but it is one of paramount importance in cases where information security is concerned.  Whenever you’re generating random data, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, or numbers in Python, it’s a good idea to have at least a rough idea of how that data was generated.&lt;/p&gt;
&lt;p&gt;Here, you’ll cover a handful of different options for generating random data in Python, and then build up to a comparison of each in terms of its level of security, versatility, purpose, and speed.&lt;/p&gt;
&lt;p&gt;I promise that this tutorial will not be a lesson in mathematics or cryptography, which I wouldn’t be well equipped to lecture on in the first place.  You’ll get into just as much math as needed, and no more.&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.ef3487c363c6.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 “Generating Random Data in 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-random/&quot; tabindex=&quot;-1&quot;&gt;
        &lt;div class=&quot;ratio ratio-16x9&quot;&gt;

            &lt;img class=&quot;card-img-top m-0 p-0 rounded&quot; style=&quot;object-fit: contain; background: #ff7e74;&quot; alt=&quot;Generating Random Data With Python&quot; src=&quot;https://files.realpython.com/media/random_data_watermark.576078a4008d.jpg&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/random_data_watermark.576078a4008d.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/random_data_watermark.576078a4008d.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/random_data_watermark.576078a4008d.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/random_data_watermark.576078a4008d.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.ef3487c363c6.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-random/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Generating Random Data in Python (Guide)&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;Test your understanding of random data in Python, from seeding the random module to generating secure tokens with secrets and uuid.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown&gt;Get Your Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-random-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-random-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to generate random and cryptographically secure data in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-random-is-random&quot;&gt;How Random Is Random?&lt;a class=&quot;headerlink&quot; href=&quot;#how-random-is-random&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First, a prominent disclaimer is necessary.  Most random data generated with Python is not fully random in the scientific sense of the word.  Rather, it is &lt;strong&gt;pseudorandom&lt;/strong&gt;: generated with a pseudorandom number generator (PRNG), which is essentially any &lt;a href=&quot;/ref/computer-science-glossary/algorithm/&quot; class=&quot;ref-link&quot;&gt;algorithm&lt;/a&gt; for generating seemingly random but still reproducible data.&lt;/p&gt;
&lt;p&gt;“True” random numbers can be generated by, you guessed it, a true random number generator (TRNG).  One example is to repeatedly pick up a die off the floor, toss it in the air, and let it land how it may.&lt;/p&gt;
&lt;p&gt;Assuming that your toss is unbiased, you have truly no idea what number the die will land on.  Rolling a die is a crude form of using hardware to generate a number that is not deterministic whatsoever.  (Or, you can have the &lt;a href=&quot;https://hackaday.com/2009/05/26/dice-o-matic/&quot;&gt;dice-o-matic&lt;/a&gt; do this for you.)  TRNGs are out of the scope of this article but worth a mention nonetheless for comparison’s sake.&lt;/p&gt;
&lt;p&gt;PRNGs, usually done with software rather than hardware, work slightly differently.  Here’s a concise description:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;They start with a random number, known as the seed, and then use an algorithm to generate a pseudo-random sequence of bits based on it.  &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom&quot;&gt;(Source)&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You’ve likely been told to “read the docs!” at some point.  Well, those people are not wrong.  Here’s a particularly notable snippet from the &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;’s documentation that you don’t want to miss:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: The pseudo-random generators of this module should not be used for security purposes. &lt;a href=&quot;https://docs.python.org/3/library/random.html&quot;&gt;(Source)&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You’ve probably seen &lt;code&gt;random.seed(999)&lt;/code&gt;, &lt;code&gt;random.seed(1234)&lt;/code&gt;, or the like, in Python.  This &lt;a href=&quot;/ref/glossary/function/&quot; class=&quot;ref-link&quot;&gt;function&lt;/a&gt; call is seeding the underlying random number generator used by Python’s &lt;code&gt;random&lt;/code&gt; module. It is what makes subsequent calls to generate random numbers deterministic: input A always produces output B.  This blessing can also be a curse if it is used maliciously.&lt;/p&gt;
&lt;p&gt;Perhaps the terms “random” and “deterministic” seem like they cannot exist next to each other.  To make that clearer, here’s an extremely trimmed down version of &lt;code&gt;random()&lt;/code&gt; that iteratively creates a “random” number by using &lt;code&gt;x = (x * 3) % 19&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is originally defined as a seed value and then morphs into a deterministic sequence of numbers based on that seed:&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;class&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NotSoRandom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;object&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;seed&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;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Seed the world&#x27;s most mysterious random number generator.&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seedval&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&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;random&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;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Look, random numbers!&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seedval&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;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seedval&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;19&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seedval&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;_inst&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NotSoRandom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;seed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_inst&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;n&quot;&gt;random&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_inst&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&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.ef3487c363c6.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;Don’t take this example too literally, as it’s meant mainly to illustrate the concept.  If you use the seed value 1234, the subsequent sequence of calls to &lt;code&gt;random()&lt;/code&gt; should always be identical:&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.ef3487c363c6.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;seed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1234&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;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&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;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[16, 10, 11, 14, 4, 12, 17, 13, 1, 3]&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;seed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1234&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;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&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;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[16, 10, 11, 14, 4, 12, 17, 13, 1, 3]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
    
    &lt;button class=&quot;codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only&quot; title=&quot;Copy to clipboard&quot; 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.ef3487c363c6.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’ll see a more serious illustration of this shortly.&lt;/p&gt;
&lt;h2 id=&quot;what-is-cryptographically-secure&quot;&gt;What Is “Cryptographically Secure?”&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-cryptographically-secure&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you haven’t had enough with the “RNG” acronyms, let’s throw one more into the mix: a CSPRNG, or cryptographically secure PRNG.  CSPRNGs are suitable for generating sensitive data such as passwords, authenticators, and tokens.  Given a random string, there is realistically no way for Malicious Joe to determine what string came before or after that string in a sequence of random strings.&lt;/p&gt;
&lt;p&gt;One other term that you may see is &lt;strong&gt;entropy&lt;/strong&gt;.  In a nutshell, this refers to the amount of randomness introduced or desired.  For example, one Python &lt;a href=&quot;https://github.com/python/cpython/blob/78392885c9b08021c89649728053d31503d8a509/Lib/secrets.py#L33&quot;&gt;module&lt;/a&gt; that you’ll cover here defines &lt;code&gt;DEFAULT_ENTROPY = 32&lt;/code&gt;, the number of bytes to return by default.  The developers deem this to be “enough” bytes to be a sufficient amount of noise.&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;: Through this tutorial, I assume that a byte refers to 8 bits, as it has since the 1960s, rather than some other unit of data storage.  You are free to call this an &lt;a href=&quot;https://en.wikipedia.org/wiki/Octet_(computing)&quot;&gt;&lt;em&gt;octet&lt;/em&gt;&lt;/a&gt; if you so prefer.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;A key point about CSPRNGs is that they are still pseudorandom.  They are engineered in some way that is internally deterministic, but they add some other &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variable&lt;/a&gt; or have some property that makes them “random enough” to prohibit backing into whatever function enforces determinism.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-random/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-random/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>Socket Programming in Python (Guide)</title>
      <id>https://realpython.com/python-sockets/</id>
      <link href="https://realpython.com/python-sockets/"/>
      <updated>2026-10-31T14:00:00+00:00</updated>
      <summary>Build a Python socket server and client from scratch, then extend it to handle multiple connections at once without blocking.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Socket programming is essential for network communication, enabling data exchange across different devices. In Python, sockets allow for &lt;a href=&quot;https://en.wikipedia.org/wiki/Inter-process_communication&quot;&gt;inter-process communication (IPC)&lt;/a&gt; over networks. This tutorial provides a comprehensive guide on creating socket servers and clients, handling multiple connections, and managing errors in Python’s &lt;code&gt;socket&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;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A socket in Python&lt;/strong&gt; is an endpoint for sending or receiving data across a network using the socket API.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Socket programming in Python&lt;/strong&gt; involves using sockets to establish communication between a server and clients over a network.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A simple echo server in Python&lt;/strong&gt; can be created using sockets to listen for client connections and echo back received messages.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Handling multiple clients with Python sockets&lt;/strong&gt; can be achieved using non-blocking sockets and the &lt;code&gt;selectors&lt;/code&gt; module for concurrent connections.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connection errors in socket programs in Python&lt;/strong&gt; can be managed by implementing error handling and using &lt;a href=&quot;/ref/glossary/exception/&quot; class=&quot;ref-link&quot;&gt;exceptions&lt;/a&gt; like &lt;code&gt;OSError&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you’ll learn about the main functions and &lt;a href=&quot;/ref/glossary/method/&quot; class=&quot;ref-link&quot;&gt;methods&lt;/a&gt; in Python’s &lt;a href=&quot;https://docs.python.org/3/library/socket.html&quot;&gt;&lt;code&gt;socket&lt;/code&gt;&lt;/a&gt; module that let you write your own client-server applications based on TCP sockets. You’ll learn how to reliably send messages and data between endpoints and handle multiple connections simultaneously.&lt;/p&gt;
&lt;p&gt;Networking and sockets are large subjects. Literal volumes have been written about them. If you’re new to sockets or networking, it’s completely normal if you feel overwhelmed with all of the terms and pieces. To get the most out of this tutorial, it’s best to download the source code and have it on hand for reference while reading:&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-sockets-source-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-sockets-source-code&quot; markdown&gt;Click here to get the working client and server code you’ll use&lt;/a&gt; to learn about socket 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.ef3487c363c6.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 “Socket Programming 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/socket-programming-in-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: #abe5b2;&quot; alt=&quot;Python Socket Programming&quot; src=&quot;https://files.realpython.com/media/Python-Sockets-Tutorial_Watermarked.aebb960a567a.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-Sockets-Tutorial_Watermarked.aebb960a567a.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Python-Sockets-Tutorial_Watermarked.aebb960a567a.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Python-Sockets-Tutorial_Watermarked.aebb960a567a.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Python-Sockets-Tutorial_Watermarked.aebb960a567a.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.ef3487c363c6.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/socket-programming-in-python/&quot; class=&quot;stretched-link&quot;&gt;&lt;span class=&quot;my-0 h4&quot;&gt;Socket Programming in Python&lt;/span&gt;&lt;/a&gt; 
      &lt;p class=&quot;text-muted mb-0 small&quot;&gt;In this quiz, you&#x27;ll test your understanding of Python sockets. With this knowledge, you&#x27;ll be able to create your own client-server applications, handle multiple connections simultaneously, and send messages and data between endpoints.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/div&gt;

&lt;h2 id=&quot;historical-background&quot;&gt;Historical Background&lt;a class=&quot;headerlink&quot; href=&quot;#historical-background&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sockets have a long history. Their use &lt;a href=&quot;https://en.wikipedia.org/wiki/Network_socket#History&quot;&gt;originated with ARPANET&lt;/a&gt; in 1971 and later became an API in the Berkeley Software Distribution (BSD) operating system released in 1983 called &lt;a href=&quot;https://en.wikipedia.org/wiki/Berkeley_sockets&quot;&gt;Berkeley sockets&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When the internet took off in the 1990s with the World Wide Web, so did network programming. Web servers and browsers weren’t the only applications taking advantage of newly connected networks and using sockets. Client-server applications of all types and sizes came into widespread use.&lt;/p&gt;
&lt;p&gt;Today, although the underlying protocols used by the socket API have evolved over the years, and new ones have developed, the low-level API has remained the same.&lt;/p&gt;
&lt;p&gt;The most common type of socket applications are client-server applications, where one side acts as the server and waits for connections from clients. This is the type of application that you’ll be creating in this tutorial. More specifically, you’ll focus on the socket API for &lt;a href=&quot;https://en.wikipedia.org/wiki/Berkeley_sockets&quot;&gt;internet sockets&lt;/a&gt;, sometimes called Berkeley or BSD sockets. There are also &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix_domain_socket&quot;&gt;Unix domain sockets&lt;/a&gt;, which can only be used to communicate between processes on the same host.&lt;/p&gt;
&lt;h2 id=&quot;python-socket-api-overview&quot;&gt;Python Socket API Overview&lt;a class=&quot;headerlink&quot; href=&quot;#python-socket-api-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s &lt;a href=&quot;https://docs.python.org/3/library/socket.html&quot;&gt;socket module&lt;/a&gt; provides an interface to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Berkeley_sockets&quot;&gt;Berkeley sockets API&lt;/a&gt;. This is the module that you’ll use in this tutorial.&lt;/p&gt;
&lt;p&gt;The primary socket API functions and methods in this module are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;socket()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.bind()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.listen()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.accept()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.connect()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.connect_ex()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.send()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.recv()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.close()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Python provides a convenient and consistent API that maps directly to system calls, their C counterparts. In the next section, you’ll learn how these are used together.&lt;/p&gt;
&lt;p&gt;As part of its standard library, Python also has classes that make using these low-level socket functions easier. Although it’s not covered in this tutorial, you can check out the &lt;a href=&quot;https://docs.python.org/3/library/socketserver.html&quot;&gt;socketserver module&lt;/a&gt;, a framework for network servers. There are also many modules available that implement higher-level internet protocols like HTTP and SMTP. For an overview, see &lt;a href=&quot;https://docs.python.org/3/library/internet.html&quot;&gt;Internet Protocols and Support&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;tcp-sockets&quot;&gt;TCP Sockets&lt;a class=&quot;headerlink&quot; href=&quot;#tcp-sockets&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You’re going to create a socket &lt;a href=&quot;/ref/glossary/object/&quot; class=&quot;ref-link&quot;&gt;object&lt;/a&gt; using &lt;code&gt;socket.socket()&lt;/code&gt;, specifying the socket type as &lt;code&gt;socket.SOCK_STREAM&lt;/code&gt;. When you do that, the default protocol that’s used is the &lt;a href=&quot;https://en.wikipedia.org/wiki/Transmission_Control_Protocol&quot;&gt;Transmission Control Protocol (TCP)&lt;/a&gt;. This is a good default and probably what you want.&lt;/p&gt;
&lt;p&gt;Why should you use TCP? The Transmission Control Protocol (TCP):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Is reliable:&lt;/strong&gt; Packets dropped in the network are detected and retransmitted by the sender.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Has in-order data delivery:&lt;/strong&gt; Data is read by your application in the order it was written by the sender.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In contrast, &lt;a href=&quot;https://en.wikipedia.org/wiki/User_Datagram_Protocol&quot;&gt;User Datagram Protocol (UDP)&lt;/a&gt; sockets created with &lt;code&gt;socket.SOCK_DGRAM&lt;/code&gt; aren’t reliable, and data read by the receiver can be out-of-order from the sender’s writes.&lt;/p&gt;
&lt;p&gt;Why is this important? Networks are a best-effort delivery system. There’s no guarantee that your data will reach its destination or that you’ll receive what’s been sent to you.&lt;/p&gt;
&lt;p&gt;Network devices, such as routers and switches, have finite bandwidth available and come with their own inherent system limitations. They have CPUs, memory, buses, and interface packet buffers, just like your clients and servers. TCP relieves you from having to worry about &lt;a href=&quot;https://en.wikipedia.org/wiki/Packet_loss&quot;&gt;packet loss&lt;/a&gt;, out-of-order data arrival, and other pitfalls that invariably happen when you’re communicating across a network.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-sockets/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-sockets/ »&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 Build a Python GUI Application With wxPython</title>
      <id>https://realpython.com/python-gui-with-wxpython/</id>
      <link href="https://realpython.com/python-gui-with-wxpython/"/>
      <updated>2026-10-31T14:00:00+00:00</updated>
      <summary>Build a cross-platform Python GUI with wxPython in this tutorial, from buttons and sizers to a working MP3 tag editor application.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;There are many graphical user interface (GUI) toolkits that you can use with the Python programming language. The big three are &lt;a href=&quot;https://realpython.com/python-gui-tkinter/&quot;&gt;Tkinter&lt;/a&gt;, wxPython, and &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/&quot;&gt;PyQt&lt;/a&gt;. Each of these toolkits will work with Windows, macOS, and Linux, with PyQt having the additional capability of working on mobile.&lt;/p&gt;
&lt;p&gt;A graphical user interface is an application that has buttons, windows, and lots of other widgets that the user can use to interact with your application. A good example would be a web browser. It has buttons, tabs, and a main window where all the content loads.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this article, you’ll learn how to build a graphical user interface with Python using the wxPython GUI toolkit.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here are the topics covered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Getting Started with wxPython&lt;/li&gt;
&lt;li&gt;Definition of a GUI&lt;/li&gt;
&lt;li&gt;Creating a Skeleton Application&lt;/li&gt;
&lt;li&gt;Creating a Working Application&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let’s start learning!&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-gui-with-wxpython-code/&quot; class=&quot;alert-link&quot; data-bs-toggle=&quot;modal&quot; data-bs-target=&quot;#modal-python-gui-with-wxpython-code&quot; markdown&gt;Click here to download the free sample code&lt;/a&gt; for the MP3 tag editor you’ll build with wxPython.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-started-with-wxpython&quot;&gt;Getting Started With wxPython&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-wxpython&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The wxPython GUI toolkit is a Python wrapper around a C++ library called &lt;a href=&quot;https://wxwidgets.org/&quot;&gt;wxWidgets&lt;/a&gt;. The initial release of wxPython was in 1998, so wxPython has been around quite a long time. wxPython’s primary difference from other toolkits, such as &lt;strong&gt;PyQt&lt;/strong&gt; or &lt;strong&gt;Tkinter&lt;/strong&gt;, is that wxPython uses the actual widgets on the native platform whenever possible. This makes wxPython applications look native to the operating system that it is running on.&lt;/p&gt;
&lt;p&gt;PyQt and Tkinter both draw their widgets themselves, which is why they don’t always match the native widgets, although PyQt is very close.&lt;/p&gt;
&lt;p&gt;This is not to say that wxPython does not support custom widgets. In fact, the wxPython toolkit has many custom widgets included with it, along with dozens upon dozens of core widgets. The wxPython &lt;a href=&quot;https://wxpython.org/pages/downloads/&quot;&gt;downloads&lt;/a&gt; page has a section called &lt;strong&gt;Extra Files&lt;/strong&gt; that is worth checking out.&lt;/p&gt;
&lt;p&gt;Here, there is a download of the wxPython Demo package. This is a nice little application that demonstrates the vast majority of the widgets that are included with wxPython. The demo allows a developer to view the code in one tab and run it in a second tab. You can even edit and re-run the code in the demo to see how your changes affect the application.&lt;/p&gt;
&lt;h3 id=&quot;installing-wxpython&quot;&gt;Installing wxPython&lt;a class=&quot;headerlink&quot; href=&quot;#installing-wxpython&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You will be using the latest wxPython for this article, which is &lt;strong&gt;wxPython 4&lt;/strong&gt;, also known as the Phoenix release. The wxPython 3 and wxPython 2 versions are built only for &lt;strong&gt;Python 2&lt;/strong&gt;. When Robin Dunn, the primary maintainer of wxPython, created the wxPython 4 release, he deprecated a lot of aliases and cleaned up a lot of code to make wxPython more &lt;a href=&quot;/ref/glossary/pythonic/&quot; class=&quot;ref-link&quot;&gt;Pythonic&lt;/a&gt; and easier to maintain.&lt;/p&gt;
&lt;p&gt;You will want to consult the following links if you are migrating from an older version of wxPython to wxPython 4 (Phoenix):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.archive.org/web/20191222230522/https://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html&quot;&gt;Classic vs Phoenix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;wxPython Project Phoenix &lt;a href=&quot;https://wxpython.org/Phoenix/docs/html/MigrationGuide.html&quot;&gt;Migration Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Current releases of wxPython 4 support only Python 3, and wxPython 4.3 requires Python 3.10 or later.&lt;/p&gt;
&lt;p&gt;You can now use &lt;code&gt;pip&lt;/code&gt; to install wxPython 4, which was not possible in the legacy versions of wxPython. You can do the following to install it on your machine:&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.ef3487c363c6.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;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;nv&quot;&gt;wxpython&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;.3.1
&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.ef3487c363c6.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;Note:&lt;/strong&gt; On macOS and Windows, &lt;code&gt;pip&lt;/code&gt; installs a prebuilt wheel, so you don’t need a compiler. Linux may also require you to install some dependencies before the &lt;code&gt;pip&lt;/code&gt; installer will work correctly.&lt;/p&gt;
&lt;p&gt;For example, on Ubuntu you’ll need development packages such as &lt;strong&gt;libgtk-3-dev&lt;/strong&gt; and &lt;strong&gt;libgstreamer-plugins-base1.0-dev&lt;/strong&gt; to get it to install.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Fortunately, the error messages that &lt;code&gt;pip&lt;/code&gt; displays are helpful in figuring out what is missing, and you can use the &lt;a href=&quot;https://github.com/wxWidgets/Phoenix/blob/master/README.rst#prerequisites&quot;&gt;prerequisites&lt;/a&gt; section on the wxPython Github page to help you find the information you need if you want to install wxPython on Linux.&lt;/p&gt;
&lt;p&gt;There are some Python &lt;a href=&quot;/ref/tools/wheel/&quot; class=&quot;ref-link&quot;&gt;wheels&lt;/a&gt; available for recent Ubuntu versions that you can find on the wxPython &lt;a href=&quot;https://github.com/wxWidgets/Phoenix/releases&quot;&gt;GitHub Releases&lt;/a&gt; page. To install one of these wheels, you would use the following command:&lt;/p&gt;
&lt;code-block class=&quot;mb-3&quot; data-syntax-language=&quot;console&quot; data-is-repl=&quot;true&quot;&gt;
  &lt;div class=&quot;codeblock__header codeblock--yellow&quot;&gt;
    &lt;span class=&quot;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.ef3487c363c6.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;nv&quot;&gt;BASE_URL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://github.com/wxWidgets/Phoenix/releases/download/wxPython-4.3.1
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;WHEEL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;wxpython-4.3.1+ubuntu2404-cp313-cp313-linux_x86_64.whl
&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;-U&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BASE_URL&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$WHEEL&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.ef3487c363c6.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;Be sure you have modified the command above to match your version of Linux.&lt;/p&gt;
&lt;h3 id=&quot;definition-of-a-gui&quot;&gt;Definition of a GUI&lt;a class=&quot;headerlink&quot; href=&quot;#definition-of-a-gui&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-gui-with-wxpython/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-gui-with-wxpython/ »&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: Socket Programming in Python</title>
      <id>https://realpython.com/quizzes/socket-programming-in-python/</id>
      <link href="https://realpython.com/quizzes/socket-programming-in-python/"/>
      <updated>2026-10-31T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of Python sockets. With this knowledge, you&#x27;ll be able to create your own client-server applications, handle multiple connections simultaneously, and send messages and data between endpoints.</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-sockets/&quot;&gt;Socket Programming in Python&lt;/a&gt;. Sockets and the socket API are used to send messages across a network. They provide a form of inter-process communication (IPC).&lt;/p&gt;
&lt;p&gt;The network can be a logical, local network to the computer, or one that&amp;rsquo;s physically connected to an external network, with its own connections to other networks. The obvious example is the internet, which you connect to via your ISP.&lt;/p&gt;
&lt;p&gt;With this quiz, you can check your understanding of the fundamentals of Python sockets. Good luck!&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>GPT-6.1 Terra Draws a Python Reading a Book</title>
      <id>https://realpython.com/ai-benchmark-gpt-6-1-terra/</id>
      <link href="https://realpython.com/ai-benchmark-gpt-6-1-terra/"/>
      <updated>2026-10-30T14:00:00+00:00</updated>
      <summary>Explore GPT-6.1 Terra&#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;GPT-6.1 Terra&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.5db43f63704e.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.5db43f63704e.png&quot; width=&quot;784&quot; height=&quot;634&quot; srcset=&quot;/cdn-cgi/image/width=196,format=auto/https://files.realpython.com/media/turtle.5db43f63704e.png 196w, /cdn-cgi/image/width=261,format=auto/https://files.realpython.com/media/turtle.5db43f63704e.png 261w, /cdn-cgi/image/width=392,format=auto/https://files.realpython.com/media/turtle.5db43f63704e.png 392w, /cdn-cgi/image/width=784,format=auto/https://files.realpython.com/media/turtle.5db43f63704e.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 GPT-6.1 Terra.&quot; data-asset=&quot;8018&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_card226299&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;#collapse226299&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapse226299&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_card226299&quot; id=&quot;collapse226299&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.7ec834dd7531.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.7ec834dd7531.gif&quot; width=&quot;784&quot; height=&quot;634&quot; srcset=&quot;/cdn-cgi/image/width=196,format=auto/https://files.realpython.com/media/turtle.7ec834dd7531.gif 196w, /cdn-cgi/image/width=261,format=auto/https://files.realpython.com/media/turtle.7ec834dd7531.gif 261w, /cdn-cgi/image/width=392,format=auto/https://files.realpython.com/media/turtle.7ec834dd7531.gif 392w, /cdn-cgi/image/width=784,format=auto/https://files.realpython.com/media/turtle.7ec834dd7531.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 GPT-6.1 Terra drawing a python reading a book.&quot; data-asset=&quot;8019&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;2853 drawing commands, 110 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.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern idioms&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;6 of 14&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;3.14.5&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;Sidestepped it&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;showed a real alternative without saying the function is made up&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;2.6k thinking tokens over all five tasks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.03&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 16 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;6.3k 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_carde6aab5&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;#collapsee6aab5&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapsee6aab5&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_carde6aab5&quot; id=&quot;collapsee6aab5&quot;&gt;
&lt;div class=&quot;card-body&quot;&gt;
&lt;p&gt;The run: &lt;code&gt;openai/gpt-6.1-terra&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-gpt-6-1-terra/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/ai-benchmark-gpt-6-1-terra/ »&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 #317: Demystifying Python Memory Management &amp; Choosing a Project Layout</title>
      <id>https://realpython.com/podcasts/rpp/317/</id>
      <link href="https://realpython.com/podcasts/rpp/317/"/>
      <updated>2026-10-30T12:00:00+00:00</updated>
      <summary>How does Python manage memory behind the scenes? What are the common ways to lay out a Python project? Christopher Trudeau is back on the show this week with another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How does Python manage memory behind the scenes? What are the common ways to lay out a Python project? 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: Python&#x27;s Mutable vs Immutable Types: What&#x27;s the Difference?</title>
      <id>https://realpython.com/quizzes/python-mutable-vs-immutable-types/</id>
      <link href="https://realpython.com/quizzes/python-mutable-vs-immutable-types/"/>
      <updated>2026-10-30T12:00:00+00:00</updated>
      <summary>Find out how Python&#x27;s mutable and immutable types behave, and see how mutability shapes lists, tuples, dictionaries, 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/python-mutable-vs-immutable-types/&quot;&gt;Python&amp;rsquo;s Mutable vs Immutable Types: What&amp;rsquo;s the Difference?&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how mutable and immutable objects differ, which built-in types fall into each group, and how mutability shows up in everyday gotchas like variable aliasing, mutable default arguments, and shallow copies.&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: Inheritance and Composition: A Python OOP Guide</title>
      <id>https://realpython.com/quizzes/inheritance-composition-python/</id>
      <link href="https://realpython.com/quizzes/inheritance-composition-python/"/>
      <updated>2026-10-30T12:00:00+00:00</updated>
      <summary>In this quiz, you&#x27;ll test your understanding of inheritance and composition in Python. These are two major concepts in object-oriented programming that help model the relationship between two classes. By working through this quiz, you&#x27;ll revisit how to use inheritance and composition in Python, model class hierarchies, and use multiple inheritance.</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/inheritance-composition-python/&quot;&gt;Inheritance and Composition in Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to use inheritance and composition in Python, model class hierarchies, and use multiple inheritance.&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: Learn With Mentor AI: A Guided Journey Through Async Python</title>
      <id>https://realpython.com/quizzes/learn-with-mentor-ai-async-python/</id>
      <link href="https://realpython.com/quizzes/learn-with-mentor-ai-async-python/"/>
      <updated>2026-10-29T12:00:00+00:00</updated>
      <summary>Practice learning async Python with Mentor AI. Check how coroutines, await, and the event loop work, and how to steer your mentor.</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/learn-with-mentor-ai-async-python/&quot;&gt;Learn With Mentor AI: A Guided Journey Through Async Python&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to steer a conversation with your mentor,
the difference between concurrency and parallelism, what calling an &lt;code&gt;async def&lt;/code&gt; function returns,
and how to avoid blocking the event loop.&lt;/p&gt;
&lt;p&gt;When you&amp;rsquo;re done, you can go further with the
&lt;a href=&quot;https://realpython.com/quizzes/python-async-features/&quot;&gt;Async Programming in Python quiz&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>Quiz: Dictionaries and Arrays: Selecting the Ideal Data Structure</title>
      <id>https://realpython.com/quizzes/dicts-arrays-ideal-data-structure/</id>
      <link href="https://realpython.com/quizzes/dicts-arrays-ideal-data-structure/"/>
      <updated>2026-10-29T12:00:00+00:00</updated>
      <summary>Test your understanding of Python dictionaries and arrays, from dict, defaultdict, and ChainMap to lists, typed arrays, and bytearray.</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/dicts-arrays-ideal-data-structure/&quot;&gt;Dictionaries and Arrays: Selecting the Ideal Data Structure&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how Python&amp;rsquo;s built-in &lt;code&gt;dict&lt;/code&gt; works, when to
reach for specialized mappings like &lt;code&gt;defaultdict&lt;/code&gt; and &lt;code&gt;ChainMap&lt;/code&gt;, and how lists, tuples,
typed arrays, strings, and binary arrays compare when you choose an array type.&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: Creating a Scalable Flask Web Application From Scratch</title>
      <id>https://realpython.com/quizzes/create-scalable-flask-web-app/</id>
      <link href="https://realpython.com/quizzes/create-scalable-flask-web-app/"/>
      <updated>2026-10-28T12:00:00+00:00</updated>
      <summary>Test your understanding of Flask project structure, from the application factory and blueprints to Jinja templates and static files.</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/create-scalable-flask-web-app/&quot;&gt;Creating a Scalable Flask Web Application From Scratch&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to set up a Flask project in a virtual
environment, organize your code with an application factory and blueprints, build pages
with Jinja templates, and link static files.&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 AI Coding Agent Workflows</title>
      <id>https://realpython.com/courses/exploring-ai-coding-agent-workflows/</id>
      <link href="https://realpython.com/courses/exploring-ai-coding-agent-workflows/"/>
      <updated>2026-10-27T14:00:00+00:00</updated>
      <summary>AI coding agents come in four types: IDE, terminal, PR, and cloud. Learn how each workflow fits into modern Python development.</summary>
      <content type="html">
        &lt;p&gt;AI coding agents can read your code, reason about changes, and act on your behalf. To choose the right one, it helps to understand the four common workflow types: integrated development environment (IDE), terminal, pull request (PR), and cloud.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Identify&lt;/strong&gt; the four common &lt;strong&gt;agent interaction modes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Understand&lt;/strong&gt; what makes &lt;strong&gt;each workflow distinct&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recognize&lt;/strong&gt; which mode fits &lt;strong&gt;common development scenarios&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Weigh&lt;/strong&gt; the &lt;strong&gt;risks and tradeoffs&lt;/strong&gt; of each workflow&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Whether you&amp;rsquo;re pairing with an agent in your editor or handing off whole tasks to the cloud, you&amp;rsquo;ll come away knowing how much control each workflow gives you and where it&amp;rsquo;s most likely to trip you up.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Codex Live Course:&lt;/strong&gt; Want hands-on practice with one of these workflows? In Real Python&amp;rsquo;s &lt;a href=&quot;https://realpython.com/workshops/codex/&quot;&gt;Codex for Python Developers&lt;/a&gt; live course, you build an entire Python project with Codex, an AI agent that works inside your codebase. The next course runs &lt;strong&gt;November 14 and 15&lt;/strong&gt;!&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>Quiz: MCP vs API Calls: Which Should You Use for Python LLM Apps?</title>
      <id>https://realpython.com/quizzes/mcp-vs-api/</id>
      <link href="https://realpython.com/quizzes/mcp-vs-api/"/>
      <updated>2026-10-27T12:00:00+00:00</updated>
      <summary>Test your understanding of MCP vs API calls in Python LLM apps, from tool schemas and MCP servers to when each approach pays off.</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/mcp-vs-api/&quot;&gt;MCP vs API Calls: Which Should You Use for Python LLM Apps?&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how direct API calls and an MCP server each
connect the same Python tool to a model, where the tool schema comes from in each approach,
how an MCP client discovers and calls tools, and when the extra server pays for itself.&lt;/p&gt;
&lt;p&gt;Good luck!&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 Out of Tutorial Hell</title>
      <id>https://realpython.com/quizzes/how-to-get-out-of-tutorial-hell/</id>
      <link href="https://realpython.com/quizzes/how-to-get-out-of-tutorial-hell/"/>
      <updated>2026-10-27T12:00:00+00:00</updated>
      <summary>Test how well you can turn Python tutorials into practical projects by specifying problems, weighing tradeoffs, and knowing when you&#x27;re done.</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/how-to-get-out-of-tutorial-hell/&quot;&gt;How to Get Out of Tutorial Hell&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit why tutorials deliberately narrow a problem,
which general skills they leave out, and how analyzing tutorials, writing your own, and
building projects help you practice specifying problems, making tradeoffs, spotting gaps
in your knowledge, and deciding when you&amp;rsquo;re done.&lt;/p&gt;
&lt;p&gt;When you&amp;rsquo;re ready to put these skills to work, pick something to build from
&lt;a href=&quot;https://realpython.com/intermediate-python-project-ideas/&quot;&gt;13 Project Ideas for Intermediate Python Developers&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>Quiz: Pyrefly: A Fast Static Type Checker for Python Projects</title>
      <id>https://realpython.com/quizzes/pyrefly-python/</id>
      <link href="https://realpython.com/quizzes/pyrefly-python/"/>
      <updated>2026-10-27T12:00:00+00:00</updated>
      <summary>Test your understanding of Pyrefly, a fast Python type checker, from catching type errors to generating type hints and measuring type coverage.</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/pyrefly-python/&quot;&gt;Pyrefly: A Fast Static Type Checker for Python Projects&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;By working through this quiz, you&amp;rsquo;ll revisit how to catch type errors with &lt;code&gt;pyrefly check&lt;/code&gt;, generate type hints with &lt;code&gt;pyrefly infer&lt;/code&gt;, and measure type coverage with &lt;code&gt;pyrefly coverage&lt;/code&gt;. You&amp;rsquo;ll also review how Pyrefly&amp;rsquo;s speed compares with mypy and Pyright, and what to consider before you switch.&lt;/p&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>AI for Beginners: Use Agents With Confidence</title>
      <id>https://realpython.com/courses/ai-agents-101/</id>
      <link href="https://realpython.com/courses/ai-agents-101/"/>
      <updated>2026-10-26T14:00:00+00:00</updated>
      <summary>Learn how AI agents really work, from models and harnesses to context and skills, so you can get better results and stay in control.</summary>
      <content type="html">
        &lt;p&gt;AI agents don&amp;rsquo;t just answer questions anymore. They read your files, search the web, and take actions on your behalf. In this video course, you&amp;rsquo;ll learn how they really work, from models and harnesses to context and skills, so you can get better results and stay in control.&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;An AI app is a &lt;strong&gt;model&lt;/strong&gt; that does the thinking, plus a &lt;strong&gt;harness&lt;/strong&gt; that carries out the actions, and many confusing replies come from that split.&lt;/li&gt;
&lt;li&gt;A model works only with what&amp;rsquo;s in its &lt;strong&gt;context&lt;/strong&gt;, so what you hand it shapes every answer.&lt;/li&gt;
&lt;li&gt;Before an agent works for you, you can check &lt;strong&gt;where it runs, what it can touch, what gets sent, and who sees it&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Asking well&lt;/strong&gt; and &lt;strong&gt;starting fresh&lt;/strong&gt; at the right time get you better results and use fewer tokens.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skills&lt;/strong&gt; let you package a job once and reuse it, and you can build your own.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you&amp;rsquo;ll practice in interactive apps and guided mentor sessions, then finish by finding and fixing five problems in an AI assistant&amp;rsquo;s setup.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Free Kit:&lt;/strong&gt; Get the &lt;a href=&quot;https://realpython.com/kits/junior-dev-ai/&quot;&gt;Junior Dev AI Starter Kit&lt;/a&gt; with videos, cheat sheets, and quizzes. You only need a free Real Python account.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Codex Live Course:&lt;/strong&gt; Ready to put an agent to work on real code? In Real Python&amp;rsquo;s &lt;a href=&quot;https://realpython.com/workshops/codex/&quot;&gt;Codex for Python Developers&lt;/a&gt; live course, you build an entire Python project with Codex, an AI agent that works inside your codebase. The next course runs &lt;strong&gt;November 14 and 15&lt;/strong&gt;!&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 #316: The Future of Python Security: Trends, Challenges, and Solutions</title>
      <id>https://realpython.com/podcasts/rpp/316/</id>
      <link href="https://realpython.com/podcasts/rpp/316/"/>
      <updated>2026-10-23T12:00:00+00:00</updated>
      <summary>How is the Python ecosystem adapting to the modern landscape of software security and supply chain defense? This week on the show, we sit down with Seth Larson, the Python Software Foundation&#x27;s Security Developer in Residence.</summary>
      <content type="html">
        &lt;p&gt;How is the Python ecosystem adapting to the modern landscape of software security and supply chain defense? This week on the show, we sit down with Seth Larson, the Python Software Foundation&#x27;s Security Developer in Residence.&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 itertools By Example</title>
      <id>https://realpython.com/courses/python-itertools-by-example/</id>
      <link href="https://realpython.com/courses/python-itertools-by-example/"/>
      <updated>2026-10-21T14:00:00+00:00</updated>
      <summary>Combine Python&#x27;s itertools functions into memory-efficient pipelines as you deal cards, analyze stock data, and pick relay teams.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;code&gt;itertools&lt;/code&gt; module is one of the hidden gems of the standard library. Knowing the definitions of its functions isn&amp;rsquo;t enough, though. Its real power lies in composing those functions into fast, memory-efficient, and readable code.&lt;/p&gt;
&lt;p&gt;Rather than introducing &lt;code&gt;itertools&lt;/code&gt; one function at a time, this video course works through practical examples that encourage you to think iteratively: you&amp;rsquo;ll shuffle and deal a deck of cards, analyze seventy years of S&amp;amp;P 500 prices, and pick relay teams for a community swim club.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The functions in &lt;code&gt;itertools&lt;/code&gt; &lt;strong&gt;operate on iterators&lt;/strong&gt; and compose into data pipelines that use far less memory than list-based code.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;batched()&lt;/code&gt; is the built-in way to &lt;strong&gt;split an iterable into chunks&lt;/strong&gt;, and it replaces the hand-rolled &lt;code&gt;grouper()&lt;/code&gt; recipe for most jobs.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;combinations()&lt;/code&gt;, &lt;code&gt;permutations()&lt;/code&gt;, and &lt;code&gt;product()&lt;/code&gt; let you &lt;strong&gt;brute-force&lt;/strong&gt; a problem, but they can trigger a combinatorial explosion.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;count()&lt;/code&gt;, &lt;code&gt;repeat()&lt;/code&gt;, &lt;code&gt;cycle()&lt;/code&gt;, and &lt;code&gt;accumulate()&lt;/code&gt; generate &lt;strong&gt;infinite sequences&lt;/strong&gt; and running totals.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pairwise()&lt;/code&gt;, &lt;code&gt;groupby()&lt;/code&gt;, &lt;code&gt;takewhile()&lt;/code&gt;, and &lt;code&gt;dropwhile()&lt;/code&gt; turn real &lt;strong&gt;data analysis&lt;/strong&gt; tasks into short, readable pipelines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The examples in this video course run on Python 3.15. You&amp;rsquo;ll need Python 3.12 or later for &lt;code&gt;batched()&lt;/code&gt;, and Python 3.15 for unpacking in comprehensions.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Intermediate Python Deep Dive Live Course:&lt;/strong&gt; Want to keep going with iterators and data pipelines? Real Python&amp;rsquo;s &lt;a href=&quot;https://realpython.com/workshops/intermediate-deep-dive/&quot;&gt;Intermediate Python Deep Dive&lt;/a&gt; live course covers advanced iteration techniques, special methods, and Python&amp;rsquo;s object model with an instructor and a small cohort. Join the waitlist to hear about the next dates.&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>Tell Your Tech Career Story: Proof, Résumés, and Interviews</title>
      <id>https://realpython.com/courses/tell-your-tech-career-story/</id>
      <link href="https://realpython.com/courses/tell-your-tech-career-story/"/>
      <updated>2026-10-20T14:00:00+00:00</updated>
      <summary>Turn your experience into a clear career story with achievement stories, proof of skills, a tailored résumé, and interview practice with Mentor AI.</summary>
      <content type="html">
        &lt;p&gt;Turn your experience into a clear story that employers notice. Choose a target role, build a bank of honest achievement stories, curate proof of your skills, and write a résumé that you can tailor for a new posting in about thirty minutes. Then practice outreach and interviews in guided mentor sessions, and finish with an application campaign for real postings.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Free Kit:&lt;/strong&gt; Get the &lt;a href=&quot;https://realpython.com/kits/tech-career-story/&quot;&gt;Tech Career Story Kit&lt;/a&gt; with career folder templates, a quick reference, and quizzes. You only need a free Real Python account.&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>Building an AI Agent With LangGraph and Python</title>
      <id>https://realpython.com/courses/building-ai-agent-langgraph-python/</id>
      <link href="https://realpython.com/courses/building-ai-agent-langgraph-python/"/>
      <updated>2026-10-20T14:00:00+00:00</updated>
      <summary>Learn LangGraph in Python with this hands-on video course and build a stateful AI agent using state graphs, nodes, and conditional edges.</summary>
      <content type="html">
        &lt;p&gt;LangGraph is a versatile Python framework designed for stateful, cyclic, and multi-actor Large Language Model (LLM) applications. LangGraph builds on its parent library, LangChain, and allows you to build sophisticated workflows that can handle the complexities of real-world LLM applications. Throughout this LangGraph video course, you&amp;rsquo;ll build a complete email-processing agent from the ground up.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll understand that:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can use LangGraph to build LLM workflows by &lt;strong&gt;defining state graphs with nodes and edges&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;LangGraph extends LangChain&amp;rsquo;s capabilities by enabling complex LLM workflows with &lt;strong&gt;state, conditional edges, and cycles&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LLM agents&lt;/strong&gt; in LangGraph autonomously process tasks by using state graphs to make decisions and interact with tools or APIs.&lt;/li&gt;
&lt;li&gt;You can use LangGraph independently of LangChain, though they&amp;rsquo;re often used together to complement each other.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Follow along with the full video course to gain hands-on experience with LangGraph, including setting up workflows and building a LangGraph agent that can autonomously parse and send emails and interact with API services.&lt;/p&gt;
&lt;p&gt;While you&amp;rsquo;ll get a brief primer on &lt;a href=&quot;https://realpython.com/build-llm-rag-chatbot-with-langchain/&quot;&gt;LangChain&lt;/a&gt; in this course, you&amp;rsquo;ll benefit from prior knowledge of LangChain fundamentals. You&amp;rsquo;ll also want to ensure you have intermediate Python knowledge, specifically in &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; concepts like classes and methods.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;AI Agent From Scratch Live Course:&lt;/strong&gt; Want to see what LangGraph does for you under the hood? In Real Python&amp;rsquo;s &lt;a href=&quot;https://realpython.com/workshops/agentic-loops/&quot;&gt;Build an AI Agent From Scratch in Python&lt;/a&gt; live course, you write the agent loop by hand, then recognize every piece of it in the tools you already use. Join the waitlist to hear about the next dates.&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 #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>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>The Real Python Podcast – Episode #314: Codemoo: Demonstrating How Coding Agents Work</title>
      <id>https://realpython.com/podcasts/rpp/314/</id>
      <link href="https://realpython.com/podcasts/rpp/314/"/>
      <updated>2026-10-09T12:00:00+00:00</updated>
      <summary>How do you assemble the core pieces of a coding agent? How are developers defining projects through conversation and introspection? This week on the show, Geir Arne Hjelle returns to talk about his recent project to demonstrate how coding agents work under the hood.</summary>
      <content type="html">
        &lt;p&gt;How do you assemble the core pieces of a coding agent? How are developers defining projects through conversation and introspection? This week on the show, Geir Arne Hjelle returns to talk about his recent project to demonstrate how coding agents work under the hood.&lt;/p&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>Exploring the MVC Pattern in Python</title>
      <id>https://realpython.com/courses/exploring-mvc-pattern-python/</id>
      <link href="https://realpython.com/courses/exploring-mvc-pattern-python/"/>
      <updated>2026-10-06T14:00:00+00:00</updated>
      <summary>Learn how the Model-View-Controller pattern organizes Python web apps, then build a small Flask app using models, views, and controllers.</summary>
      <content type="html">
        &lt;p&gt;If you&amp;rsquo;re curious about web development, then you&amp;rsquo;ve likely encountered the abbreviation &lt;strong&gt;MVC&lt;/strong&gt;, which stands for &lt;a href=&quot;https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller&quot;&gt;Model-View-Controller&lt;/a&gt;. You may know that it&amp;rsquo;s a common design pattern that&amp;rsquo;s fundamental to many Python web frameworks and even desktop applications.&lt;/p&gt;
&lt;p&gt;But what exactly does it mean? If you&amp;rsquo;ve had a hard time wrapping your head around the concept, then this video course is for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn what &lt;strong&gt;models&lt;/strong&gt;, &lt;strong&gt;views&lt;/strong&gt;, and &lt;strong&gt;controllers&lt;/strong&gt; are &lt;strong&gt;conceptually&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Follow a &lt;strong&gt;user&amp;rsquo;s request&lt;/strong&gt; through an MVC application from end to end&lt;/li&gt;
&lt;li&gt;Tie your conceptual understanding back to &lt;strong&gt;concrete web development examples&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build a small &lt;strong&gt;Flask&lt;/strong&gt; app that puts the MVC pattern into practice&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #313: Python 3.15: Exploring the New Features</title>
      <id>https://realpython.com/podcasts/rpp/313/</id>
      <link href="https://realpython.com/podcasts/rpp/313/"/>
      <updated>2026-10-02T12:00:00+00:00</updated>
      <summary>Python 3.15 is (almost*) here! Christopher Trudeau and Bartosz Zaczyński return to discuss the new version. Bartosz coordinated the series of preview articles with members of the Real Python team and wrote the showcase tutorial, &quot;Python 3.15: Cool New Features for You to Try.&quot; Christopher&#x27;s video course &quot;What&#x27;s New in Python 3.15&quot; covers the topics from the article and shows the new features in action.</summary>
      <content type="html">
        &lt;p&gt;Python 3.15 is (almost*) here! Christopher Trudeau and Bartosz Zaczyński return to discuss the new version. Bartosz coordinated the series of preview articles with members of the Real Python team and wrote the showcase tutorial, &quot;Python 3.15: Cool New Features for You to Try.&quot; Christopher&#x27;s video course &quot;What&#x27;s New in Python 3.15&quot; covers the topics from the article and shows the new features in action.&lt;/p&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>Community Videos</title>
      <id>https://realpython.com/courses/community-videos/</id>
      <link href="https://realpython.com/courses/community-videos/"/>
      <updated>2026-09-30T14:00:00+00:00</updated>
      <summary>Watch Real Python&#x27;s YouTube videos right here on the site, with the resources mentioned in each video and a full transcript.</summary>
      <content type="html">
        &lt;p&gt;This collection gathers the videos that the Real Python team published on the &lt;a href=&quot;https://www.youtube.com/@realpython&quot;&gt;Real Python YouTube channel&lt;/a&gt;, so you can watch them right here on Real Python.&lt;/p&gt;
&lt;p&gt;Each lesson contains the full video, the resources mentioned in it, and a transcript. The newest video is always at the top, and new videos are added as they&amp;rsquo;re released.&lt;/p&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>What&#x27;s New in Python 3.15</title>
      <id>https://realpython.com/courses/whats-new-in-python-315/</id>
      <link href="https://realpython.com/courses/whats-new-in-python-315/"/>
      <updated>2026-09-29T14:00:00+00:00</updated>
      <summary>Explore the new features in Python 3.15, including lazy imports, frozendict, sentinel values, a sampling profiler, and a faster JIT.</summary>
      <content type="html">
        &lt;p&gt;Python 3.15 is here! After a last-minute third release candidate, the &lt;a href=&quot;https://www.python.org/downloads/release/python-3150/&quot;&gt;final release&lt;/a&gt; came out on October 9, 2026, so you can install it today and start using the new features in your own code. This is a good time to see what the new version has in store for you.&lt;/p&gt;
&lt;p&gt;This release trims the time you spend waiting. Imports can wait until you need them, the JIT compiler got faster, and a new profiler shows you where the remaining slow parts hide. There&amp;rsquo;s also plenty in it for everyday code, including two new built-in types.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll explore features like:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lazy imports&lt;/strong&gt; with the new &lt;code&gt;lazy&lt;/code&gt; keyword&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;frozendict&lt;/code&gt;&lt;/strong&gt;, an immutable mapping in the built-ins&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;sentinel&lt;/code&gt;&lt;/strong&gt;, a clean way to say &amp;ldquo;no value given&amp;rdquo;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A sampling profiler&lt;/strong&gt; that you can point at a running process&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;UTF-8&lt;/strong&gt; as the default encoding everywhere&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;An upgraded JIT compiler&lt;/strong&gt; with measurable speedups&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #312: Navigating AI in Open Source: Insights From Wagtail</title>
      <id>https://realpython.com/podcasts/rpp/312/</id>
      <link href="https://realpython.com/podcasts/rpp/312/"/>
      <updated>2026-09-25T12:00:00+00:00</updated>
      <summary>How should you manage AI contributions to an open-source project? How do you measure the impact of using AI tools for development, and what generative features do end users want from a content management system? This week on the show, we speak with Thibaud Colas and Meagen Voss from Wagtail about the complex considerations software organizations are currently facing.</summary>
      <content type="html">
        &lt;p&gt;How should you manage AI contributions to an open-source project? How do you measure the impact of using AI tools for development, and what generative features do end users want from a content management system? This week on the show, we speak with Thibaud Colas and Meagen Voss from Wagtail about the complex considerations software organizations are currently facing.&lt;/p&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>Using the Claude API in Python</title>
      <id>https://realpython.com/courses/using-claude-api-python/</id>
      <link href="https://realpython.com/courses/using-claude-api-python/"/>
      <updated>2026-09-22T14:00:00+00:00</updated>
      <summary>Learn how to use the Claude API in Python to send prompts, control responses with system instructions, and get structured output.</summary>
      <content type="html">
        &lt;p&gt;The fastest way to use the Claude API in Python is to install &lt;code&gt;anthropic&lt;/code&gt;, set your API key, and call &lt;code&gt;client.messages.create()&lt;/code&gt;. You&amp;rsquo;ll have a working response in under a minute.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/ref/ai-coding-tools/claude/&quot; class=&quot;ref-link&quot;&gt;Claude&lt;/a&gt; is Anthropic&amp;rsquo;s &lt;a href=&quot;/ref/ai-coding-glossary/llm/&quot; class=&quot;ref-link&quot;&gt;large language model&lt;/a&gt;, accessible via a clean &lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;REST API&lt;/a&gt; with an official Python SDK. Unlike heavier AI frameworks that require you to wire up multiple components before you see any output, the &lt;code&gt;anthropic&lt;/code&gt; package gets you to a working response in a handful of lines.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll install the &lt;code&gt;anthropic&lt;/code&gt; SDK, call Claude from Python, shape Claude&amp;rsquo;s behavior with a &lt;a href=&quot;/ref/ai-coding-glossary/system-prompt/&quot; class=&quot;ref-link&quot;&gt;system prompt&lt;/a&gt;, and then return structured &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;JSON&lt;/a&gt; output using &lt;a href=&quot;https://realpython.com/python-pydantic/&quot;&gt;Pydantic&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Claude&amp;rsquo;s responses are non-deterministic, so the same prompt produces different output each time, which is expected for a large language model. Also, API calls cost money based on the number of &lt;a href=&quot;/ref/ai-coding-glossary/token/&quot; class=&quot;ref-link&quot;&gt;tokens&lt;/a&gt; processed. Keep an eye on your usage in the Claude Console as you follow along.&lt;/p&gt;
&lt;p&gt;Each lesson builds on the last, and the final script is short enough to read in one sitting but complete enough to extend into a real application of your own.&lt;/p&gt;
        &lt;hr /&gt;
        
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
        
      </content>
    </entry>
  
    <entry>
      <title>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>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>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 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>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>
