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

  
    <entry>
      <title>The Real Python Podcast – Episode #151: Evaluating Python Packages &amp; Celebrating 20 Years of PyCon US</title>
      <id>https://realpython.com/podcasts/rpp/151/</id>
      <link href="https://realpython.com/podcasts/rpp/151/"/>
      <updated>2023-03-31T12:00:00+00:00</updated>
      <summary>Have you ever installed a Python package without knowing anything about it? What best practices should you employ to ensure the quality of your next package installation? Christopher Trudeau is back this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects. We also have Python Software Foundation executive director, Deb Nicholson, to share details about PyCon US 2023.</summary>
      <content type="html">
        &lt;p&gt;Have you ever installed a Python package without knowing anything about it? What best practices should you employ to ensure the quality of your next package installation? Christopher Trudeau is back this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects. We also have Python Software Foundation executive director, Deb Nicholson, to share details about PyCon US 2023.&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>Build a Maze Solver in Python Using Graphs</title>
      <id>https://realpython.com/python-maze-solver/</id>
      <link href="https://realpython.com/python-maze-solver/"/>
      <updated>2023-03-29T14:00:00+00:00</updated>
      <summary>In this step-by-step project, you&#x27;ll build a maze solver in Python using graph algorithms from the NetworkX library. Along the way, you&#x27;ll design a binary file format for the maze, represent it in an object-oriented way, and visualize the solution using scalable vector graphics (SVG).</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’re up for a little challenge and would like to take your programming skills to the next level, then you’ve come to the right place! In this hands-on tutorial, you’ll practice object-oriented programming, among several other good practices, while building a cool maze solver project in Python.&lt;/p&gt;
&lt;p&gt;From reading a maze from a binary file, to visualizing it using scalable vector graphics (SVG), to finding the shortest path from the entrance to the exit, you’ll go step by step through the guided process of building a complete and working project.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use an &lt;strong&gt;object-oriented approach&lt;/strong&gt; to represent the maze in memory&lt;/li&gt;
&lt;li&gt;Define a specialized &lt;strong&gt;binary file format&lt;/strong&gt; to store the maze on disk&lt;/li&gt;
&lt;li&gt;Transform the maze into a traversable &lt;strong&gt;weighted graph&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;graph search algorithms&lt;/strong&gt; in the NetworkX library to find the solution&lt;/li&gt;
&lt;li&gt;Visualize the maze and its solution using &lt;strong&gt;scalable vector graphics (SVG)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click the link below to download the complete source code for this project, along with the supporting materials, which include a few sample mazes:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-maze-solver-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-maze-solver-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the source code and supporting materials&lt;/a&gt; that you’ll use to build a maze solver in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;demo-python-maze-solver&quot;&gt;Demo: Python Maze Solver&lt;a class=&quot;headerlink&quot; href=&quot;#demo-python-maze-solver&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;At the end of this tutorial, you’ll have a command-line maze solver that can load your maze from a binary file and show its solution in the web browser:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/796253152?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;You’ll learn how to build your own mazes like this from scratch and save them on disk. In the meantime, feel free to grab one of the sample mazes from the supporting materials. Now, get ready to dive in!&lt;/p&gt;
&lt;h2 id=&quot;project-overview&quot;&gt;Project Overview&lt;a class=&quot;headerlink&quot; href=&quot;#project-overview&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Take a glimpse at the expected file structure of your project. Once finished, your project’s file and directory tree will look as follows:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;maze-solver/
│
├── mazes/
│   ├── labyrinth.maze
│   ├── miniature.maze
│   └── pacman.maze
│
├── src/
│   │
│   └── maze_solver/
│       │
│       ├── graphs/
│       │   ├── __init__.py
│       │   ├── converter.py
│       │   └── solver.py
│       │
│       ├── models/
│       │   ├── __init__.py
│       │   ├── border.py
│       │   ├── edge.py
│       │   ├── maze.py
│       │   ├── role.py
│       │   ├── solution.py
│       │   └── square.py
│       │
│       ├── persistence/
│       │   ├── __init__.py
│       │   ├── file_format.py
│       │   └── serializer.py
│       │
│       ├── view/
│       │   ├── __init__.py
│       │   ├── decomposer.py
│       │   ├── primitives.py
│       │   └── renderer.py
│       │
│       ├── __init__.py
│       └── __main__.py
│
├── pyproject.toml
└── requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yes, that’s a lot of files, but don’t worry! Most of them are fairly short, and some contain only a few lines of code. This helps keep things organized and makes the individual pieces reusable, letting you compose them in new ways. Such granularity also plays an important role in Python projects with larger codebases by avoiding the notorious &lt;a href=&quot;https://en.wikipedia.org/wiki/Circular_dependency&quot;&gt;circular dependency&lt;/a&gt; error that you might encounter if various parts of the code were in one big file.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;mazes/&lt;/code&gt; subfolder is home to a few binary files with sample data that you’re going to use in this tutorial. You can get these files, along with the final source code and snapshots of the individual steps, by downloading the supporting materials:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-maze-solver-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-maze-solver-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the source code and supporting materials&lt;/a&gt; that you’ll use to build a maze solver in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;src/&lt;/code&gt; subfolder contains your &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;Python modules and packages&lt;/a&gt; for the maze solver project. The &lt;code&gt;maze_solver&lt;/code&gt; package consists of several subpackages that group logically related code fragments, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;graphs&lt;/code&gt;&lt;/strong&gt;: The traversal and conversion of the maze to a graph representation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;models&lt;/code&gt;&lt;/strong&gt;: The building blocks of the maze and its solution&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;persistence&lt;/code&gt;&lt;/strong&gt;: A custom binary file format for persistent maze storage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;view&lt;/code&gt;&lt;/strong&gt;: The visualization of the graph with scalable vector graphics&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll also find the special &lt;a href=&quot;https://docs.python.org/3/library/__main__.html&quot;&gt;&lt;code&gt;__main__.py&lt;/code&gt;&lt;/a&gt; file, which makes the enclosing package runnable so that you can execute it directly from the command line using Python’s &lt;code&gt;-m&lt;/code&gt; option:&lt;/p&gt;
&lt;div class=&quot;highlight sh&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 -m maze_solver /path/to/sample.maze
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When launched like this, the package reads the specified file with your maze. After solving the maze, it renders the solution into an SVG format embedded in a temporary HTML file. The file gets automatically opened in your default web browser. You can also run the same Python code using a shortcut command:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;solve /path/to/sample.maze
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It’ll work as long the &lt;code&gt;solve&lt;/code&gt; command isn’t already taken or &lt;a href=&quot;https://en.wikipedia.org/wiki/Alias_(command)&quot;&gt;aliased&lt;/a&gt; by another program.&lt;/p&gt;
&lt;p&gt;Finally, &lt;code&gt;pyproject.toml&lt;/code&gt; provides your project’s configuration, metadata, and dependencies defined in the &lt;a href=&quot;https://realpython.com/python-toml/&quot;&gt;TOML&lt;/a&gt; format. The project only depends on one external library, which you’ll use to find the shortest path in the maze represented as a graph.&lt;/p&gt;
&lt;p&gt;Next up, you’ll review a list of relevant resources that might become your savior in case you get stuck at any point. Also, remember the supporting materials, which contain a snapshot of each finished step. Along the way, you can compare your progress to the relevant step to ensure that you’re on the right track.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-maze-solver/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-maze-solver/ »&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>YAML: Python&#x27;s Missing Battery</title>
      <id>https://realpython.com/courses/yaml-python/</id>
      <link href="https://realpython.com/courses/yaml-python/"/>
      <updated>2023-03-28T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about working with YAML in Python. By the end of it, you&#x27;ll know about the available libraries, their strengths and weaknesses, and the advanced and potentially dangerous features of YAML.</summary>
      <content type="html">
        &lt;p&gt;Python is often marketed as a &lt;em&gt;batteries-included&lt;/em&gt; language because it comes with almost everything you&amp;rsquo;d ever expect from a programming language. This statement is mostly true, as the standard library and the external modules cover a broad spectrum of programming needs. However, Python lacks built-in support for the &lt;strong&gt;YAML data format&lt;/strong&gt;, commonly used for configuration and serialization.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll learn how to work with YAML in Python using the available third-party libraries, with a focus on &lt;strong&gt;PyYAML&lt;/strong&gt;. If you&amp;rsquo;re new to YAML or haven&amp;rsquo;t used it in a while, then you&amp;rsquo;ll have a chance to take a quick crash course before diving deeper into the topic.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Read&lt;/strong&gt; and &lt;strong&gt;write&lt;/strong&gt; YAML documents in Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serialize&lt;/strong&gt; Python&amp;rsquo;s &lt;strong&gt;built-in&lt;/strong&gt; and &lt;strong&gt;custom&lt;/strong&gt; data types to YAML&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Safely&lt;/strong&gt; read YAML documents from &lt;strong&gt;untrusted sources&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notably, you&amp;rsquo;ll learn about YAML&amp;rsquo;s advanced, potentially dangerous features and how to protect yourself from them.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Read Python Input as Integers</title>
      <id>https://realpython.com/python-input-integer/</id>
      <link href="https://realpython.com/python-input-integer/"/>
      <updated>2023-03-27T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use Python to get integer input from the user while handling any errors resulting from non-numeric input. This will involve coding your own reusable function built around input().</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you’ve ever coded an &lt;strong&gt;interactive text-based application&lt;/strong&gt; in Python, then you’ve probably found that you need a reliable way of asking the user for integers as input. It’s not enough simply to display a prompt and then gather keystrokes. You must check that the user’s input really represents an integer. If it doesn’t, then your code must react appropriately—typically by repeating the prompt.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn how to create a &lt;strong&gt;reusable utility function&lt;/strong&gt; that’ll guarantee &lt;strong&gt;valid integer inputs&lt;/strong&gt; from an interactive user. Along the way, you’ll learn about Python’s tools for getting a string from the console and converting that string into an integer.&lt;/p&gt;
&lt;p&gt;Whenever you’re writing a program that interacts with the keyboard, you must code defensively to manage invalid inputs, so you’ll also learn the most Pythonic way to deal with this situation. You’ll handle any errors robustly inside a function that’s guaranteed to return nothing but integers.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-input-integer-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-input-integer-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the sample code&lt;/a&gt; that you’ll use to get integer input from users in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-get-integer-input-values-in-python&quot;&gt;How to Get Integer Input Values in Python&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-get-integer-input-values-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python’s standard library provides a built-in tool for getting string input from the user, the &lt;a href=&quot;https://realpython.com/python-input-output/#reading-input-from-the-keyboard&quot;&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/a&gt; function. Before you start using this function, double-check that you’re on a version of Python 3. If you’d like to learn why that’s so important, then check out the collapsible section below:&lt;/p&gt;
&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_card425a9c&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-toggle=&quot;collapse&quot; data-target=&quot;#collapse425a9c&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapse425a9c&quot; markdown=&quot;1&quot;&gt;&lt;span class=&quot;float-left&quot; markdown=&quot;1&quot;&gt;Why you should beware of Python 2&#x27;s &lt;code&gt;input()&lt;/code&gt; function&lt;/span&gt;&lt;span class=&quot;float-right 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-parent=&quot;#collapse_card425a9c&quot; id=&quot;collapse425a9c&quot;&gt;
&lt;div class=&quot;card-body&quot;&gt;
&lt;p&gt;Python 2’s version of the &lt;code&gt;input()&lt;/code&gt; function was unsafe because the interpreter would actually &lt;a href=&quot;https://realpython.com/python-exec/#avoiding-input-from-untrusted-sources&quot;&gt;execute&lt;/a&gt; the string returned by the function before the calling program had any opportunity to verify it. This allowed a malicious user to inject arbitrary code into the program. &lt;/p&gt;
&lt;p&gt;Because of this issue, Python 2 also provided the &lt;code&gt;raw_input()&lt;/code&gt; function as a much safer alternative, but there was always the risk that an unsuspecting programmer might choose the more obviously-named &lt;code&gt;input()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Python 3 renamed &lt;code&gt;raw_input()&lt;/code&gt; to &lt;code&gt;input()&lt;/code&gt; and removed the old, risky version of &lt;code&gt;input()&lt;/code&gt;. In this tutorial, you’ll use Python 3, so this pitfall won’t be a concern.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In Python 3, the &lt;code&gt;input()&lt;/code&gt; function returns a &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;&lt;code&gt;string&lt;/code&gt;&lt;/a&gt;, so you need to convert it to an &lt;a href=&quot;https://realpython.com/python-numbers/#integers&quot;&gt;integer&lt;/a&gt;. You can read the string, convert it to an integer, and &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;print&lt;/a&gt; the results in three lines of code:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;number_as_string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Please enter an integer: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Please enter an integer: 123&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;number_as_integer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number_as_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The value of the integer is &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number_as_integer&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;The value of the integer is 123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When the above snippet of code is executed, the interpreter pauses at the &lt;code&gt;input()&lt;/code&gt; function and prompts the user to input an integer. A blinking cursor shows up at the end of the prompt, and the system waits for the user to type an arbitrary string of characters.&lt;/p&gt;
&lt;p&gt;When the user presses the &lt;span class=&quot;keys&quot;&gt;&lt;kbd class=&quot;key-enter&quot;&gt;Enter&lt;/kbd&gt;&lt;/span&gt; key, the function returns a string containing the characters as typed, without a newline. As a reminder that the received value is a string, you’ve named the receiving variable &lt;code&gt;number_as_string&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Your next line attempts to parse &lt;code&gt;number_as_string&lt;/code&gt; as an integer and store the result in &lt;code&gt;number_as_integer&lt;/code&gt;. You use the &lt;a href=&quot;https://docs.python.org/3/library/functions.html#int&quot;&gt;&lt;code&gt;int()&lt;/code&gt;&lt;/a&gt; class constructor to perform the conversion. 
Finally, the &lt;code&gt;print()&lt;/code&gt; function displays the result. &lt;/p&gt;
&lt;h2 id=&quot;dealing-with-invalid-input&quot;&gt;Dealing With Invalid Input&lt;a class=&quot;headerlink&quot; href=&quot;#dealing-with-invalid-input&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You’ve probably already noticed that the above code is hopelessly optimistic. You can’t always rely on users to provide the kind of input that you expect. You can help a lot by providing an explicit prompt message, but through confusion, carelessness, or malice, there’ll always be users who provide invalid input. Your program should be ready to deal with any kind of text.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-input-integer/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-input-integer/ »&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 #150: Lessons Learned From Four Years Programming With Python</title>
      <id>https://realpython.com/podcasts/rpp/150/</id>
      <link href="https://realpython.com/podcasts/rpp/150/"/>
      <updated>2023-03-24T12:00:00+00:00</updated>
      <summary>What are the core lessons you&#x27;ve learned along your Python development journey? What are key takeaways you would share with new users of the language? This week on the show, Duarte Oliveira e Carmo is here to discuss his recent talk, &quot;Four Years of Python.&quot;</summary>
      <content type="html">
        &lt;p&gt;What are the core lessons you&#x27;ve learned along your Python development journey? What are key takeaways you would share with new users of the language? This week on the show, Duarte Oliveira e Carmo is here to discuss his recent talk, &quot;Four Years of Python.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>When Should You Use .__repr__() vs .__str__() in Python?</title>
      <id>https://realpython.com/python-repr-vs-str/</id>
      <link href="https://realpython.com/python-repr-vs-str/"/>
      <updated>2023-03-22T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn the difference between the string representations returned by .__repr__() vs .__str__() and understand how to use them effectively in classes that you define.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;One of the most common tasks that a computer program performs is to &lt;strong&gt;display data&lt;/strong&gt;. The program often displays this information to the program’s user. However, a program also needs to show information to the programmer developing and maintaining it. The information a programmer needs about an object differs from how the program should display the same object for the user, and that’s where &lt;code&gt;.__repr__()&lt;/code&gt; vs &lt;code&gt;.__str__()&lt;/code&gt; comes in.&lt;/p&gt;
&lt;p&gt;A Python object has several special methods that provide specific behavior. There are two similar &lt;strong&gt;special methods&lt;/strong&gt; that describe the object using a string representation. These methods are &lt;code&gt;.__repr__()&lt;/code&gt; and &lt;code&gt;.__str__()&lt;/code&gt;. The &lt;code&gt;.__repr__()&lt;/code&gt; method returns a &lt;strong&gt;detailed description&lt;/strong&gt; for a programmer who needs to maintain and debug the code. The &lt;code&gt;.__str__()&lt;/code&gt; method returns a &lt;strong&gt;simpler description&lt;/strong&gt; with information for the user of the program.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.__repr__()&lt;/code&gt; and &lt;code&gt;.__str__()&lt;/code&gt; methods are two of the special methods that you can define for any class. They allow you to control how a program displays an object in several common forms of output, such as what you get from the &lt;code&gt;print()&lt;/code&gt; function, formatted strings, and interactive environments.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn how to differentiate &lt;code&gt;.__repr__()&lt;/code&gt; vs &lt;code&gt;.__str__()&lt;/code&gt; and how to use these special methods in the classes you define. Defining these methods effectively makes the classes that you write more readable and easier to debug and maintain. So, &lt;strong&gt;when should you choose Python’s &lt;code&gt;.__repr__()&lt;/code&gt; vs &lt;code&gt;.__str__&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-tricks-sample-pdf/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-tricks-sample-pdf&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Get a sample chapter from Python Tricks: The Book&lt;/a&gt; that shows you Python’s best practices with simple examples you can apply instantly to write more beautiful + Pythonic code.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;in-short-use-__repr__-for-programmers-vs-__str__-for-users&quot;&gt;In Short: Use &lt;code&gt;.__repr__()&lt;/code&gt; for Programmers vs &lt;code&gt;.__str__()&lt;/code&gt; for Users&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-use-__repr__-for-programmers-vs-__str__-for-users&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python classes have a number of &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#special-method-names&quot;&gt;special methods&lt;/a&gt;. These methods have a double leading underscore and a double trailing underscore in their names. You can informally refer to them as dunder methods because of the &lt;strong&gt;d&lt;/strong&gt;ouble &lt;strong&gt;under&lt;/strong&gt;scores in their names.&lt;/p&gt;
&lt;p&gt;The special methods &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__repr__&quot;&gt;&lt;code&gt;.__repr__()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__str__&quot;&gt;&lt;code&gt;.__str__()&lt;/code&gt;&lt;/a&gt; both return string representations of the object. A string representation is a string that shows information about the object. You can tailor this information for different audiences, such as program users or your fellow programmers.&lt;/p&gt;
&lt;p&gt;Like with other special methods with leading and trailing double underscores in their names, you can define these methods for any class.&lt;/p&gt;
&lt;p&gt;The reason there are two methods to display an object is that they have different purposes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.__repr__()&lt;/code&gt; provides the &lt;strong&gt;official string representation&lt;/strong&gt; of an object, aimed at the programmer.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.__str__()&lt;/code&gt; provides the &lt;strong&gt;informal string representation&lt;/strong&gt; of an object, aimed at the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The target audience for the string representation returned by &lt;code&gt;.__repr__()&lt;/code&gt; is the programmer developing and maintaining the program. In general, it provides detailed and unambiguous information about the object. Another important property of the official string representation is that a programmer can normally use it to re-create an object equal to the original one. &lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.__str__()&lt;/code&gt; method provides a string representation targeted to the program’s user, who may not necessarily be a Python programmer. Therefore, this representation enables any user to understand the data contained in the object. Usually, it’s simpler and easier to read for a user.&lt;/p&gt;
&lt;p&gt;One way of displaying both representations of an object is by using &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;Python’s standard REPL&lt;/a&gt;. The REPL will display the string representation from &lt;code&gt;.__repr__()&lt;/code&gt; when you evaluate a line that only has an object on it. However, the built-in function &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; shows the informal string representation returned by &lt;code&gt;.__str__()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can view the strings returned by &lt;code&gt;.__repr__()&lt;/code&gt; vs &lt;code&gt;.__str__()&lt;/code&gt; for an instance of the &lt;code&gt;datetime&lt;/code&gt; class in the &lt;a href=&quot;https://realpython.com/python-datetime/&quot;&gt;&lt;code&gt;datetime&lt;/code&gt;&lt;/a&gt; module:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;datetime&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;today&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&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;today&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;datetime.datetime(2023, 2, 18, 18, 40, 2, 160890)&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2023-02-18 18:40:02.160890&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You create a &lt;code&gt;datetime.datetime&lt;/code&gt; object named &lt;code&gt;today&lt;/code&gt; using &lt;a href=&quot;https://docs.python.org/3/library/datetime.html#datetime.datetime.now&quot;&gt;&lt;code&gt;.now()&lt;/code&gt;&lt;/a&gt;. This method returns the current date and time. When you evaluate the line containing only the variable name &lt;code&gt;today&lt;/code&gt;, the REPL displays the string representation returned by &lt;code&gt;.__repr__()&lt;/code&gt;. This representation shows the name of the data type and all the arguments needed to re-create the object.&lt;/p&gt;
&lt;p&gt;When you use &lt;code&gt;print()&lt;/code&gt;, the REPL displays the representation returned by &lt;code&gt;.__str__()&lt;/code&gt;. This string shows the &lt;a href=&quot;https://www.iso.org/iso-8601-date-and-time-format.html&quot;&gt;ISO standard format&lt;/a&gt; for displaying dates and times. Therefore, this is not a Python-specific format but a standard that’s used more broadly to represent dates and times.&lt;/p&gt;
&lt;p&gt;Often, the official string representation is a valid Python expression that you can use to create a new object with the same value. You can confirm this with the &lt;code&gt;datetime.datetime&lt;/code&gt; object by copying the official string representation and assigning it to a new name. You can also attempt to use the informal string representation, but this won’t work:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;new_date&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;datetime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2023&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;18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&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;160890&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;new_date&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;today&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_date&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2023&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;02.160890&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;input&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;new_date&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2023&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;02&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;02.160890&lt;/span&gt;
                          &lt;span class=&quot;pm&quot;&gt;^&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;SyntaxError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;leading zeros in decimal integer literals are not permitted ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output you got from &lt;code&gt;.__repr__()&lt;/code&gt; when you evaluated &lt;code&gt;today&lt;/code&gt; in the REPL created a new object equal to the original one.&lt;/p&gt;
&lt;p&gt;However, the string representation from &lt;code&gt;.__str__()&lt;/code&gt;, which you got when you used &lt;code&gt;print()&lt;/code&gt;, isn’t a valid Python expression, so it raises a &lt;code&gt;SyntaxError&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can also show the string representations for common built-in data types:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;5&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;greeting&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;How are you?&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;greeting&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;How are you?&#x27;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;How are you?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Python’s REPL returns the official string representation defined by &lt;code&gt;.__repr__()&lt;/code&gt; when you evaluate a line that includes only the object or its variable name. But what’s happening with &lt;code&gt;print()&lt;/code&gt;? In the examples above, the official string representation is identical or nearly the same as the informal string representation, which &lt;code&gt;print()&lt;/code&gt; returns. Both representations are based largely on the &lt;a href=&quot;https://docs.python.org/3/reference/expressions.html#literals&quot;&gt;literals&lt;/a&gt; that you used to create the objects.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-repr-vs-str/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-repr-vs-str/ »&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>Summing Values the Pythonic Way With sum()</title>
      <id>https://realpython.com/courses/python-sum-function/</id>
      <link href="https://realpython.com/courses/python-sum-function/"/>
      <updated>2023-03-21T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to use Python&#x27;s sum() function to add numeric values together. You&#x27;ll also learn how to concatenate sequences, such as lists and tuples, using sum().</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s built-in function &lt;code&gt;sum()&lt;/code&gt; is an efficient and &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;Pythonic&lt;/a&gt; way to sum a list of numeric values. Adding several numbers together is a common intermediate step in many computations, so &lt;code&gt;sum()&lt;/code&gt; is a pretty handy tool for a Python programmer.&lt;/p&gt;
&lt;p&gt;As an additional and interesting use case, you can concatenate &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;lists and tuples&lt;/a&gt; using &lt;code&gt;sum()&lt;/code&gt;, which can be convenient when you need to flatten a list of lists.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sum numeric values by hand using &lt;strong&gt;general techniques and tools&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Python&amp;rsquo;s &lt;code&gt;sum()&lt;/code&gt;&lt;/strong&gt; to add several numeric values efficiently&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Concatenate lists and tuples&lt;/strong&gt; with &lt;code&gt;sum()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;sum()&lt;/code&gt; to approach common &lt;strong&gt;summation problems&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use appropriate values for the &lt;strong&gt;arguments&lt;/strong&gt; in &lt;code&gt;sum()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Decide between &lt;code&gt;sum()&lt;/code&gt; and &lt;strong&gt;alternative tools&lt;/strong&gt; to sum and concatenate objects&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This knowledge will help you efficiently approach and solve summation problems in your code using either &lt;code&gt;sum()&lt;/code&gt; or other alternative and specialized tools.&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>Executing Python Scripts With a Shebang</title>
      <id>https://realpython.com/python-shebang/</id>
      <link href="https://realpython.com/python-shebang/"/>
      <updated>2023-03-20T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn when and how to use the shebang line in your Python scripts to execute them from a Unix-like shell. Along the way, you&#x27;ll run custom scripts written in your domain-specific language interpreted by Python.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you read someone else’s Python code, you frequently see a mysterious line, which always appears at the top of the file, starting with the distinctive shebang (&lt;code&gt;#!&lt;/code&gt;) sequence. It looks like a not-so-useful comment, but other than that, it doesn’t resemble anything else you’ve learned about Python, making you wonder what that is and why it’s there. As if that wasn’t enough to confuse you, the shebang line only appears in some Python modules.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn &lt;strong&gt;what&lt;/strong&gt; a shebang is&lt;/li&gt;
&lt;li&gt;Decide &lt;strong&gt;when&lt;/strong&gt; to include the shebang in Python scripts&lt;/li&gt;
&lt;li&gt;Define the shebang in a &lt;strong&gt;portable&lt;/strong&gt; way across systems&lt;/li&gt;
&lt;li&gt;Pass &lt;strong&gt;arguments&lt;/strong&gt; to the command defined in a shebang&lt;/li&gt;
&lt;li&gt;Know the shebang’s &lt;strong&gt;limitations&lt;/strong&gt; and some of its alternatives&lt;/li&gt;
&lt;li&gt;Execute scripts through a &lt;strong&gt;custom interpreter&lt;/strong&gt; written in Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To proceed, you should have basic familiarity with the &lt;a href=&quot;https://realpython.com/command-line-interfaces-python-argparse/&quot;&gt;command line&lt;/a&gt; and know how to &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run Python scripts&lt;/a&gt; from it. You can also download the supporting materials for this tutorial to follow along with the code examples:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-shebang-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-shebang-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to execute Python scripts with a shebang.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;whats-a-shebang-and-when-should-you-use-it&quot;&gt;What’s a Shebang, and When Should You Use It?&lt;a class=&quot;headerlink&quot; href=&quot;#whats-a-shebang-and-when-should-you-use-it&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In short, a &lt;a href=&quot;https://en.wikipedia.org/wiki/Shebang_(Unix)&quot;&gt;shebang&lt;/a&gt; is a special kind of &lt;a href=&quot;https://realpython.com/python-comments-guide/&quot;&gt;comment&lt;/a&gt; that you may include in your source code to tell the operating system’s &lt;a href=&quot;https://en.wikipedia.org/wiki/Shell_(computing)&quot;&gt;shell&lt;/a&gt; where to find the interpreter for the rest of the file:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;ch&quot;&gt;#!/usr/bin/python3&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;p&gt;If you’re using a shebang, it must appear on the &lt;strong&gt;first line&lt;/strong&gt; in your script, and it has to start with a &lt;a href=&quot;https://en.wikipedia.org/wiki/Number_sign&quot;&gt;hash sign (&lt;code&gt;#&lt;/code&gt;)&lt;/a&gt; followed by an &lt;a href=&quot;https://en.wikipedia.org/wiki/Exclamation_mark&quot;&gt;exclamation mark (&lt;code&gt;!&lt;/code&gt;)&lt;/a&gt;, colloquially known as the bang, hence the name &lt;em&gt;shebang&lt;/em&gt;. The choice of the hash sign to begin this special sequence of characters wasn’t accidental, as many &lt;a href=&quot;https://en.wikipedia.org/wiki/Scripting_language&quot;&gt;scripting languages&lt;/a&gt; use it for inline comments.&lt;/p&gt;
&lt;p&gt;You should make sure you don’t put any other comments before the shebang line if you want it to work correctly, or else it won’t be recognized! After the exclamation mark, specify an &lt;strong&gt;absolute path&lt;/strong&gt; to the relevant code interpreter, such as Python. Providing a relative path will have no effect, unfortunately.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The shebang is only recognized by shells, such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Z_shell&quot;&gt;Z shell&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Bash_(Unix_shell)&quot;&gt;Bash&lt;/a&gt;, running on &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix-like&quot;&gt;Unix-like&lt;/a&gt; operating systems, including macOS and Linux distributions. It bears no particular meaning in the &lt;a href=&quot;https://realpython.com/python-coding-setup-windows/#discovering-the-windows-terminal&quot;&gt;Windows terminal&lt;/a&gt;, which treats the shebang as an ordinary comment by ignoring it.&lt;/p&gt;
&lt;p&gt;You can get the shebang to work on Windows by installing the &lt;a href=&quot;https://realpython.com/effective-python-environment/#windows-subsystem-for-linux&quot;&gt;Windows Subsystem for Linux (WSL)&lt;/a&gt; that comes with a Unix shell. Alternatively, Windows lets you make a global &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/shell/fa-how-work&quot;&gt;file association&lt;/a&gt; between a file extension like &lt;code&gt;.py&lt;/code&gt; and a program, such as the Python interpreter, to achieve a similar effect.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;It’s not uncommon to combine a shebang with the &lt;a href=&quot;https://realpython.com/if-name-main-python/&quot;&gt;name-main idiom&lt;/a&gt;, which prevents the main block of code from running when someone imports the file from another module:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;ch&quot;&gt;#!/usr/bin/python3&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;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;p&gt;With this &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional statement&lt;/a&gt;, Python will call the &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt; function only when you run this module directly as a script—for example, by providing its path to the Python interpreter:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python3 /path/to/your/script.py
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As long as the script’s content starts with a correctly defined shebang line and your system user has &lt;a href=&quot;https://en.wikipedia.org/wiki/File-system_permissions&quot;&gt;permission to execute&lt;/a&gt; the corresponding file, you can omit the &lt;code&gt;python3&lt;/code&gt; command to run that script:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;/path/to/your/script.py
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A shebang is only relevant to &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;runnable scripts&lt;/a&gt; that you wish to execute without explicitly specifying the program to run them through. You wouldn’t typically put a shebang in a &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;Python module&lt;/a&gt; that only contains &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;function&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/#define-a-class-in-python&quot;&gt;class definitions&lt;/a&gt; meant for &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;importing&lt;/a&gt; from other modules. Therefore, use the shebang when you don’t want to prefix the command that runs your Python script with &lt;code&gt;python&lt;/code&gt; or &lt;code&gt;python3&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In the old days of Python, the shebang line would sometimes appear alongside another specially formatted comment described in &lt;a href=&quot;https://peps.python.org/pep-0263/&quot;&gt;PEP 263&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;ch&quot;&gt;#!/usr/bin/python3&lt;/span&gt;
&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -*- coding: utf-8 -*-&lt;/span&gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;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;Grüß Gott&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The highlighted line used to be necessary to tell the interpreter which &lt;a href=&quot;https://realpython.com/python-encodings-guide/&quot;&gt;character encoding&lt;/a&gt; it should use to read your source code correctly, as Python defaulted to &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot;&gt;ASCII&lt;/a&gt;. However, this was only important when you directly embedded non-Latin characters, such as ü or ß, in your code.&lt;/p&gt;
&lt;p&gt;This special comment is irrelevant today because modern Python versions use the universal UTF-8 encoding, which can handle such characters with ease. Nevertheless, it’s always preferable to replace tricky characters with their encoded representations using Unicode literals:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;s2&quot;&gt;&quot;Grüß Gott&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;unicode_escape&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;b&#x27;Gr\\xfc\\xdf Gott&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Your foreign colleagues who have different keyboard layouts will thank you for that!&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Now that you have a high-level understanding of &lt;em&gt;what&lt;/em&gt; a shebang is and &lt;em&gt;when&lt;/em&gt; to use it, you’re ready to explore it in more detail. In the next section, you’ll take a closer look at &lt;em&gt;how&lt;/em&gt; it works.&lt;/p&gt;
&lt;h2 id=&quot;how-does-a-shebang-work&quot;&gt;How Does a Shebang Work?&lt;a class=&quot;headerlink&quot; href=&quot;#how-does-a-shebang-work&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Normally, to run a program in the &lt;a href=&quot;https://realpython.com/terminal-commands/&quot;&gt;terminal&lt;/a&gt;, you must provide the full path to a particular &lt;strong&gt;binary executable&lt;/strong&gt; or the name of a command present in one of the directories listed on the &lt;a href=&quot;https://en.wikipedia.org/wiki/PATH_(variable)&quot;&gt;&lt;code&gt;PATH&lt;/code&gt;&lt;/a&gt; environment variable. One or more command-line arguments may follow this path or command:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;/usr/bin/python3 -c &lt;span class=&quot;s1&quot;&gt;&#x27;print(&quot;Hello, World!&quot;)&#x27;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python3 -c &lt;span class=&quot;s1&quot;&gt;&#x27;print(&quot;Hello, World!&quot;)&#x27;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, you run the Python interpreter in a non-interactive mode against a &lt;a href=&quot;https://en.wikipedia.org/wiki/One-liner_program&quot;&gt;one-liner program&lt;/a&gt; passed through the &lt;code&gt;-c&lt;/code&gt; option. In the first case, you provide an absolute path to &lt;code&gt;python3&lt;/code&gt;, while in the second case, you rely on the fact that the parent folder, &lt;code&gt;/usr/bin/&lt;/code&gt;, is included on the search path by default. Your shell can find the Python executable, even if you don’t provide the full path, by looking through the directories on the &lt;code&gt;PATH&lt;/code&gt; variable.&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 multiple commands with the same name exist in more than one directory listed on the &lt;code&gt;PATH&lt;/code&gt; variable, then your shell will execute the first it can find. As a result, the outcome of running a command without explicitly specifying the corresponding path may sometimes be surprising. It’ll depend on the order of directories in your &lt;code&gt;PATH&lt;/code&gt; variable. However, this can be useful, as you’ll find out later.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-shebang/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-shebang/ »&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 #149: Coding With namedtuple &amp; Python&#x27;s Dynamic Superpowers</title>
      <id>https://realpython.com/podcasts/rpp/149/</id>
      <link href="https://realpython.com/podcasts/rpp/149/"/>
      <updated>2023-03-17T12:00:00+00:00</updated>
      <summary>Have you explored Python&#x27;s collections module? Within it, you&#x27;ll find a powerful factory function called namedtuple(), which provides multiple enhancements over the standard tuple for writing clearer and cleaner code. This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Have you explored Python&#x27;s collections module? Within it, you&#x27;ll find a powerful factory function called namedtuple(), which provides multiple enhancements over the standard tuple for writing clearer and cleaner code. This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Evaluate the Quality of Python Packages</title>
      <id>https://realpython.com/python-package-quality/</id>
      <link href="https://realpython.com/python-package-quality/"/>
      <updated>2023-03-15T14:00:00+00:00</updated>
      <summary>Just like you shouldn&#x27;t download any file from the Internet, you shouldn&#x27;t install third-party Python packages without evaluating them first. This tutorial will give you the tool set to evaluate the quality of external Python packages before you incorporate them into your Python projects.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Installing packages with Python is just one &lt;code&gt;pip install&lt;/code&gt; command away.
That’s one of the many great qualities that the Python ecosystem has to offer.&lt;/p&gt;
&lt;p&gt;However, you may have downloaded a &lt;strong&gt;third-party package&lt;/strong&gt; once that didn’t work out for you in one way or another.
For example, the package didn’t support the Python version that you were using in your project, or the package didn’t do what you expected it to do.&lt;/p&gt;
&lt;p&gt;By understanding the characteristics of a high-quality Python package, you can avoid introducing incompatible or even harmful code into your project.
In this tutorial, you’ll learn how the &lt;strong&gt;Python Package Index&lt;/strong&gt; can give you a first impression of a package. Then you’ll dig even deeper by checking out &lt;strong&gt;Libraries.io&lt;/strong&gt;, the &lt;strong&gt;GitHub repository&lt;/strong&gt;, and the &lt;strong&gt;license&lt;/strong&gt; of any Python package that you want to use.&lt;/p&gt;
&lt;p&gt;In the end, you’ll know how to evaluate third-party packages that you can find online before you implement them into your Python projects.&lt;/p&gt;
&lt;p&gt;For future reference, you can also download this handy &lt;strong&gt;flowchart&lt;/strong&gt; that’ll help you decide if a third-party Python package works for your particular situation:&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Bonus Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-package-quality-flowchart/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-package-quality-flowchart&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free flowchart&lt;/a&gt; that you can use to evaluate the quality of Python packages.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;how-to-evaluate-the-quality-of-third-party-python-packages&quot;&gt;How to Evaluate the Quality of Third-Party Python Packages&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-evaluate-the-quality-of-third-party-python-packages&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://pypi.org&quot;&gt;Python Package Index&lt;/a&gt; (PyPI) provides the largest collection of external &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;Python packages&lt;/a&gt;. Before you &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;install a package with &lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;, you should make sure that it’s available on PyPI:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/pypi-website.f5b943521a31.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/pypi-website.f5b943521a31.png&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pypi-website.f5b943521a31.png&amp;amp;w=480&amp;amp;sig=50048f995bb11834641ede026351f9b038c65350 480w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pypi-website.f5b943521a31.png&amp;amp;w=640&amp;amp;sig=024b90be8919fde0d023edb4e69275399c9d8ec3 640w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pypi-website.f5b943521a31.png&amp;amp;w=960&amp;amp;sig=f26c8017098eed2654196a5e79c96d68e113f326 960w, https://files.realpython.com/media/pypi-website.f5b943521a31.png 1920w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Screenshot of the PyPI website&quot; data-asset=&quot;4941&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Being able to find the package on PyPI is a good indicator that it’s legit, although you still need to be careful about what you’re getting.&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; It’s possible to &lt;code&gt;pip install&lt;/code&gt; a package from a &lt;a href=&quot;https://realpython.com/what-is-pip/#installing-packages-from-your-github-repositories&quot;&gt;Git repository&lt;/a&gt; or directly install a &lt;a href=&quot;https://realpython.com/python-wheels/&quot;&gt;Python wheel&lt;/a&gt; you find online.&lt;/p&gt;
&lt;p&gt;While you can download a Python package from anywhere, you should ask yourself if the package is high-quality and safe.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;On PyPI, you’ve got the option to either browse categories or search for keywords. 
Unless you’re looking for a very niche package, chances are that PyPI will present you with a list of thousands of packages that match your topic.&lt;/p&gt;
&lt;p&gt;To sort the order of the list, PyPI gives you two options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Relevance&lt;/li&gt;
&lt;li&gt;Date last updated&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The option to sort by &lt;em&gt;Relevance&lt;/em&gt; is ambiguous because you don’t know what PyPI takes into consideration for this order. 
Still, when you sort by relevance, the packages appearing on top are indeed often the ones that suit your needs:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/803895539?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;Sometimes, it can be tricky to find the right package on PyPI, even if you know the package’s name.
For example, when you search for &lt;em&gt;&lt;a href=&quot;https://realpython.com/beautiful-soup-web-scraper-python/&quot;&gt;beautiful soup&lt;/a&gt;&lt;/em&gt;, then you’ll get a number of similar-looking results.
That’s when &lt;em&gt;Relevance&lt;/em&gt; can come in handy.&lt;/p&gt;
&lt;p&gt;Out of curiosity, you may also peek into the packages that have been updated lately by using the &lt;em&gt;Date last updated&lt;/em&gt; order.
But usually the sorting makes irrelevant packages appear on top, just because they were updated recently.&lt;/p&gt;
&lt;p&gt;In most cases, a package doesn’t need to be cutting-edge unless it addresses a security issue.
Instead, it’s important that a package supports the &lt;strong&gt;Python version&lt;/strong&gt; of your project.
This is when the PyPI filter comes into play:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/803895781?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;For example, when you want to use the &lt;a href=&quot;https://realpython.com/python311-new-features/&quot;&gt;cool new features of Python 3.11&lt;/a&gt; to full capacity, then you can select &lt;em&gt;Python 3.11&lt;/em&gt; in the list of &lt;em&gt;Programming Languages&lt;/em&gt; filters.&lt;/p&gt;
&lt;p&gt;Additionally, you can combine filters on PyPI.
It’s a good idea to also add &lt;strong&gt;Development Status&lt;/strong&gt; into your consideration by filtering for &lt;em&gt;Production/Stable&lt;/em&gt;, too.
This way, you increase the chances of working with reliable packages that have gone through thorough testing.&lt;/p&gt;
&lt;p&gt;When you’ve found a package that seems to fit your needs, then it’s time to put it under the microscope to make sure it’s safe and reliable. For this evaluation, you’ll study the &lt;strong&gt;PyPI details page&lt;/strong&gt;.
Clicking a package name brings you to a page that’s dedicated to the package:&lt;/p&gt;
&lt;figure&gt;
  &lt;div class=&quot;embed-responsive embed-responsive-16by9 rounded mb-3 border&quot;&gt;
    &lt;iframe loading=&quot;lazy&quot; class=&quot;embed-responsive-item&quot; src=&quot;https://player.vimeo.com/video/803895646?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-package-quality/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-package-quality/ »&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 Projects With Sphinx and Read the Docs</title>
      <id>https://realpython.com/courses/python-sphinx/</id>
      <link href="https://realpython.com/courses/python-sphinx/"/>
      <updated>2023-03-14T14:00:00+00:00</updated>
      <summary>In this video series, you&#x27;ll create project documentation from scratch using Sphinx, the de facto standard for Python. You&#x27;ll also hook your code repository up to Read The Docs to automatically build and publish your code documentation.</summary>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.sphinx-doc.org/&quot;&gt;Sphinx&lt;/a&gt; is a document generation tool that&amp;rsquo;s become the de facto standard for Python projects. It uses the &lt;a href=&quot;https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html&quot;&gt;reStructuredText&lt;/a&gt; (RST) markup language to define document structure and styling, and it can output in a wide variety of formats, including &lt;a href=&quot;https://realpython.com/html-css-python/&quot;&gt;HTML&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/EPUB&quot;&gt;ePub&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Man_page&quot;&gt;man pages&lt;/a&gt;, and much more. Sphinx is extendable and has plugins for incorporating &lt;a href=&quot;https://docs.python.org/3/library/pydoc.html&quot;&gt;pydoc&lt;/a&gt; comments from your code into your docs and for using &lt;a href=&quot;https://jupyterbook.org/en/stable/content/myst.html&quot;&gt;MyST Markdown&lt;/a&gt; instead of RST.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://readthedocs.org/&quot;&gt;Read the Docs&lt;/a&gt; is a free document hosting site where many Python projects host their documentation. It integrates with &lt;a href=&quot;https://realpython.com/python-git-github-intro/&quot;&gt;GitHub&lt;/a&gt;, &lt;a href=&quot;https://about.gitlab.com/&quot;&gt;GitLab&lt;/a&gt;, and &lt;a href=&quot;https://bitbucket.org/&quot;&gt;Bitbucket&lt;/a&gt; to automatically pull new documentation sources from your repositories and build their Sphinx sources.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write your documentation with &lt;strong&gt;Sphinx&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Structure and style your document with &lt;strong&gt;RST syntax&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Incorporate your &lt;strong&gt;pydoc&lt;/strong&gt; comments into your documentation&lt;/li&gt;
&lt;li&gt;Host your documentation on &lt;strong&gt;Read the Docs&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With these skills, you&amp;rsquo;ll be able to write clear, reliable documentation that&amp;rsquo;ll help your users get the most out of your project.&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 News: What&#x27;s New From February 2023</title>
      <id>https://realpython.com/python-news-february-2023/</id>
      <link href="https://realpython.com/python-news-february-2023/"/>
      <updated>2023-03-13T14:00:00+00:00</updated>
      <summary>February 2023 was a busy month for Python, with a new pandas 2.0.0 release candidate, exciting developments at pydantic, and more offerings at OpenAI. In addition, software and package security has been a key issue across the Python ecosystem.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;February is the shortest month, but it brought no shortage of activity in the Python world! Exciting developments include a &lt;strong&gt;new company&lt;/strong&gt; aiming to improve cloud services for developers, publication of the &lt;strong&gt;PyCon US 2023 schedule&lt;/strong&gt;, and the first release candidate for &lt;strong&gt;pandas 2.0.0&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In the world of artifical intelligence, &lt;strong&gt;OpenAI&lt;/strong&gt; has continued to make strides. But while the &lt;strong&gt;Big Fix&lt;/strong&gt; has worked to reduce vulnerabily for programmers, more &lt;strong&gt;malicious programs&lt;/strong&gt; showed up on PyPI. &lt;/p&gt;
&lt;p&gt;Read on to dive into the biggest &lt;strong&gt;Python news&lt;/strong&gt; from the last month.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Join Now:&lt;/strong&gt; &lt;a href=&quot;&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-newsletter&quot; data-focus=&quot;false&quot;&gt;Click here to join the Real Python Newsletter&lt;/a&gt; and you&#x27;ll never miss another Python tutorial, course update, or post.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;pydantic-launches-commercial-venture&quot;&gt;Pydantic Launches Commercial Venture&lt;a class=&quot;headerlink&quot; href=&quot;#pydantic-launches-commercial-venture&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;With over 40 million downloads per month, &lt;a href=&quot;https://pydantic.dev/&quot;&gt;pydantic&lt;/a&gt; is the most-used data validation library in Python. So when its founder, &lt;a href=&quot;https://twitter.com/samuel_colvin?lang=en&quot;&gt;Samuel Colvin&lt;/a&gt;, announces &lt;a href=&quot;https://twitter.com/samuel_colvin/status/1626237293618147329&quot;&gt;successful seed funding&lt;/a&gt;, there’s plenty of reason to believe there’s a game changer in the works.&lt;/p&gt;
&lt;p&gt;In his announcement, Colvin compares the current state of &lt;strong&gt;cloud services&lt;/strong&gt; to that of a tractor fifteen years after its invention. In both cases, the technology gets the job done, but without much consideration for the person in the driver’s seat.&lt;/p&gt;
&lt;p&gt;Colvin’s new company builds on what pydantic has learned about putting developer experience and expertise first. The exact details of this new venture are still under wraps, but it sets out to answer these questions:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What if we could build a platform with the best of all worlds? Taking the final step in reducing the boilerplate and busy-work of building web applications — allowing developers to write nothing more than the core logic which makes their application unique and valuable? (&lt;a href=&quot;https://pydantic.dev/announcement/&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This doesn’t mean that the open-source project is going anywhere. In fact, &lt;a href=&quot;https://docs.pydantic.dev/blog/pydantic-v2/&quot;&gt;pydantic V2&lt;/a&gt; is on its way and will be around seventeen times faster than V1, thanks to being rewritten in &lt;a href=&quot;https://www.rust-lang.org/&quot;&gt;Rust&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To stay on up to date on what’s happening with pydantic’s new venture, subscribe to the &lt;a href=&quot;https://github.com/pydantic/pydantic/issues/5063&quot;&gt;GitHub issue&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-february-2023/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-february-2023/ »&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 #148: Sharing Your Python App Across Platforms With BeeWare</title>
      <id>https://realpython.com/podcasts/rpp/148/</id>
      <link href="https://realpython.com/podcasts/rpp/148/"/>
      <updated>2023-03-10T12:00:00+00:00</updated>
      <summary>Are you interested in deploying your Python project everywhere? This week on the show, Russell Keith-Magee, founder and maintainer of the BeeWare project, returns. Russell shares recent updates to Briefcase, a tool that converts a Python application into native installers on macOS, Windows, Linux, and mobile devices.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in deploying your Python project everywhere? This week on the show, Russell Keith-Magee, founder and maintainer of the BeeWare project, returns. Russell shares recent updates to Briefcase, a tool that converts a Python application into native installers on macOS, Windows, Linux, and mobile devices.&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&#x27;s Mutable vs Immutable Types: What&#x27;s the Difference?</title>
      <id>https://realpython.com/python-mutable-vs-immutable-types/</id>
      <link href="https://realpython.com/python-mutable-vs-immutable-types/"/>
      <updated>2023-03-08T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how Python mutable and immutable data types work internally and how you can take advantage of mutability or immutability to power your code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;As a Python developer, you’ll have to deal with &lt;strong&gt;mutable&lt;/strong&gt; and &lt;strong&gt;immutable&lt;/strong&gt; objects sooner or later. Mutable objects are those that allow you to change their value or data in place without affecting the object’s identity. In contrast, immutable objects don’t allow this kind of operation. You’ll just have the option of creating new objects of the same type with different values.&lt;/p&gt;
&lt;p&gt;In Python, mutability is a characteristic that may profoundly influence your decision when choosing which data type to use in solving a given programming problem. Therefore, you need to know how mutable and immutable objects work in Python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand how &lt;strong&gt;mutability&lt;/strong&gt; and &lt;strong&gt;immutability&lt;/strong&gt; work under the hood in Python&lt;/li&gt;
&lt;li&gt;Explore immutable and mutable &lt;strong&gt;built-in data types&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Identify and avoid some common &lt;strong&gt;mutability-related gotchas&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Understand and control how mutability affects your &lt;strong&gt;custom classes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To dive smoothly into this fundamental Python topic, you should be familiar with how &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; work in Python. You should also know the basics of Python’s built-in &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;data types&lt;/a&gt;, such as &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;tuples, lists&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionaries&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-sets/&quot;&gt;sets&lt;/a&gt;, and others. Finally, knowing how &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; works in Python is also a good starting point.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-mutable-vs-immutable-types-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-mutable-vs-immutable-types-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that you’ll use to explore mutable vs immutable data types in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;mutability-vs-immutability&quot;&gt;Mutability vs Immutability&lt;a class=&quot;headerlink&quot; href=&quot;#mutability-vs-immutability&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In programming, you have an &lt;strong&gt;immutable object&lt;/strong&gt; if you can’t change the object’s &lt;a href=&quot;https://en.wikipedia.org/wiki/State_(computer_science)&quot;&gt;state&lt;/a&gt; after you’ve created it. In contrast, a &lt;strong&gt;mutable object&lt;/strong&gt; allows you to modify its internal state after creation. In short, whether you’re able to change an object’s state or contained data is what defines if that object is mutable or immutable.&lt;/p&gt;
&lt;p&gt;Immutable objects are common in &lt;a href=&quot;https://realpython.com/python-functional-programming/&quot;&gt;functional programming&lt;/a&gt;, while mutable objects are widely used in &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;. Because Python is a multiparadigm programming language, it provides mutable and immutable objects for you to choose from when solving a problem.&lt;/p&gt;
&lt;p&gt;To understand how mutable and immutable objects work in Python, you first need to understand a few related concepts. To kick things off, you’ll take a look at variables and objects.&lt;/p&gt;
&lt;h3 id=&quot;variables-and-objects&quot;&gt;Variables and Objects&lt;a class=&quot;headerlink&quot; href=&quot;#variables-and-objects&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Python, &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; don’t have an associated type or size, as they’re labels attached to objects in memory. They point to the memory position where concrete objects live. In other words, a Python variable is a name that &lt;em&gt;refers to&lt;/em&gt; or holds a &lt;em&gt;reference to&lt;/em&gt; a concrete object. In contrast, Python &lt;strong&gt;objects&lt;/strong&gt; are concrete pieces of information that live in specific memory positions on your computer.&lt;/p&gt;
&lt;p&gt;The main takeaway here is that variables and objects are two different animals in Python:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variables&lt;/strong&gt; hold references to objects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Objects&lt;/strong&gt; live in concrete memory positions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both concepts are independent of each other. However, they’re closely related. Once you’ve created a variable with an &lt;a href=&quot;https://realpython.com/python-assignment-operator/&quot;&gt;assignment statement&lt;/a&gt;, then you can access the referenced object throughout your code by using the variable name. If the referenced object is mutable, then you can also perform &lt;strong&gt;mutations&lt;/strong&gt; on it through the variable. Mutability or immutability is intrinsic to objects rather than to variables.&lt;/p&gt;
&lt;p&gt;However, if the referenced object is immutable, then you won’t be able to change its internal state or contained data. You’ll just be able to make your variable reference a different object that, in Python, may or may not be of the same type as your original object.&lt;/p&gt;
&lt;p&gt;If you don’t have a reference (variable) to an object, then you can’t access that object in your code. If you lose or remove all the references to a given object, then Python will &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-garbage-collection&quot;&gt;garbage-collect&lt;/a&gt; that object, freeing the memory for later use.&lt;/p&gt;
&lt;p&gt;Now that you know that there are differences between variables and objects, you need to learn that all Python objects have three core properties: identity, type, and value.&lt;/p&gt;
&lt;h3 id=&quot;objects-value-identity-and-type&quot;&gt;Objects, Value, Identity, and Type&lt;a class=&quot;headerlink&quot; href=&quot;#objects-value-identity-and-type&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Python, everything is an object. For example, &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/#define-a-class-in-python&quot;&gt;classes&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;modules&lt;/a&gt; are all objects. Every Python object has three core characteristics that define it at a foundational level. These characteristics are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Value&lt;/li&gt;
&lt;li&gt;Identity&lt;/li&gt;
&lt;li&gt;Type&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Arguably, the &lt;strong&gt;value&lt;/strong&gt; is probably the most familiar object characteristic that you’ve dealt with. An object’s value consists of the concrete piece or pieces of &lt;strong&gt;data&lt;/strong&gt; contained in the object itself. A classic example is a numeric value like an &lt;a href=&quot;https://realpython.com/python-numbers/#integers&quot;&gt;integer&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-numbers/#floating-point-numbers&quot;&gt;floating-point&lt;/a&gt; number:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;42&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isinstance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3.14&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isinstance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These numeric values, &lt;code&gt;42&lt;/code&gt; and &lt;code&gt;3.14&lt;/code&gt;, are both objects. The first number is an instance of the built-in &lt;a href=&quot;https://docs.python.org/3/library/functions.html#int&quot;&gt;&lt;code&gt;int&lt;/code&gt;&lt;/a&gt; class, while the second is an instance of &lt;a href=&quot;https://docs.python.org/3/library/functions.html#float&quot;&gt;&lt;code&gt;float&lt;/code&gt;&lt;/a&gt;. In both examples, you confirm the object’s type using the built-in &lt;a href=&quot;https://docs.python.org/3/library/functions.html#isinstance&quot;&gt;&lt;code&gt;isinstance()&lt;/code&gt;&lt;/a&gt; function.&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; In this tutorial, you’ll use the term &lt;strong&gt;value&lt;/strong&gt; to refer to an object’s data. Your objects will have custom and meaningful values only if you add those values yourself. Sometimes, you’ll create or find objects that don’t have meaningful values. However, all Python objects contain built-in attributes that also hold data. So, in a way, each Python object has an implicit value.&lt;/p&gt;
&lt;p&gt;For example, all Python objects will have &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-special-method&quot;&gt;special methods&lt;/a&gt; and attributes that the language adds automatically under the hood:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;obj&lt;/span&gt; &lt;span class=&quot;o&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;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;obj&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__class__&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__delattr__&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    ...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__str__&#x27;,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    &#x27;__subclasshook__&#x27;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you created a generic object using the built-in &lt;a href=&quot;https://docs.python.org/3/library/functions.html#object&quot;&gt;&lt;code&gt;object&lt;/code&gt;&lt;/a&gt; class. You haven’t added any attributes to the object. So, from your programming perspective, this object doesn’t have a meaningful value. So, you may think it only has identity and type, which  you’ll explore in just a moment.&lt;/p&gt;
&lt;p&gt;However, because all objects have built-in attributes, you can mutate them by adding new attributes and data dynamically, as you’ll learn in the &lt;a href=&quot;#mutability-in-custom-classes&quot;&gt;Mutability in Custom Classes&lt;/a&gt; section of this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-mutable-vs-immutable-types/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-mutable-vs-immutable-types/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Manipulating ZIP Files With Python</title>
      <id>https://realpython.com/courses/zipfile-python/</id>
      <link href="https://realpython.com/courses/zipfile-python/"/>
      <updated>2023-03-07T16:40:12+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to manipulate ZIP files using Python&#x27;s zipfile module from the standard library. Through hands-on examples, you&#x27;ll learn how to read, write, compress, and extract files from your ZIP files quickly.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;a href=&quot;https://docs.python.org/3/library/zipfile.html&quot;&gt;&lt;code&gt;zipfile&lt;/code&gt;&lt;/a&gt; is a standard-library module intended to manipulate &lt;strong&gt;ZIP files&lt;/strong&gt;. This file format is a widely adopted industry standard when it comes to archiving and compressing digital data. You can use it to package together several related files. It also allows you to reduce the size of your files and save disk space. Most importantly, it facilitates data exchange over computer networks.&lt;/p&gt;
&lt;p&gt;Knowing how to create, read, write, populate, extract, and list ZIP files using the &lt;code&gt;zipfile&lt;/code&gt; module is a useful skill to have as a Python developer or a DevOps engineer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Read, write, and extract&lt;/strong&gt; files from ZIP files with Python&amp;rsquo;s &lt;code&gt;zipfile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Read &lt;strong&gt;metadata&lt;/strong&gt; about the content of ZIP files using &lt;code&gt;zipfile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;zipfile&lt;/code&gt; to &lt;strong&gt;manipulate member files&lt;/strong&gt; in existing ZIP files&lt;/li&gt;
&lt;li&gt;Create &lt;strong&gt;new ZIP files&lt;/strong&gt; to archive and compress files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you commonly deal with ZIP files, then this knowledge can help to streamline your workflow to process your files confidently.&lt;/p&gt;
&lt;p&gt;To get the most out of this video course, you should know the basics of &lt;a href=&quot;https://realpython.com/courses/practical-recipes-files/&quot;&gt;working with files&lt;/a&gt;, using the &lt;a href=&quot;https://realpython.com/courses/with-statement-python/&quot;&gt;&lt;code&gt;with&lt;/code&gt; statement&lt;/a&gt;, handling file system paths with &lt;a href=&quot;https://realpython.com/courses/pathlib-python/&quot;&gt;&lt;code&gt;pathlib&lt;/code&gt;&lt;/a&gt;, and working with classes and &lt;a href=&quot;https://realpython.com/courses/intro-object-oriented-programming-oop-python/&quot;&gt;object-oriented programming&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;d like to learn more about the REPL used in this course, check out &lt;a href=&quot;https://realpython.com/bpython-alternative-python-repl/&quot;&gt;Discover bpython: A Python REPL With IDE-Like Features&lt;/a&gt;. Note that all the code in this course will also run in the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;Python standard REPL&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>What&#x27;s a Python Namespace Package, and What&#x27;s It For?</title>
      <id>https://realpython.com/python-namespace-package/</id>
      <link href="https://realpython.com/python-namespace-package/"/>
      <updated>2023-03-06T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll be exploring Python namespace packages: what they are, what they&#x27;re for, and how you can use them in your package systems. Along the way, you&#x27;ll create your own set of namespace packages and explore how you might be able to use them in your own projects.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python &lt;strong&gt;namespace packages&lt;/strong&gt; are an advanced Python feature. You may have heard them mentioned in relation to the &lt;code&gt;__init__.py&lt;/code&gt; file. Specifically, if you &lt;em&gt;don’t&lt;/em&gt; include at least an empty &lt;code&gt;__init__.py&lt;/code&gt; file in your package, then your package becomes a namespace package.&lt;/p&gt;
&lt;p&gt;For the most part, namespace packages and &lt;strong&gt;regular packages&lt;/strong&gt; won’t behave differently when it comes to using them in your project. In fact, you’ve probably accidentally forgotten to include an &lt;code&gt;__init__.py&lt;/code&gt; file in at least one package but didn’t notice any side effects. While namespace packages are generally a bit slower to &lt;strong&gt;import&lt;/strong&gt; than regular packages, you won’t usually run into many issues.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll dive into what Python namespace packages are, where they come from, why they’re created when you don’t include an &lt;code&gt;__init__.py&lt;/code&gt; file, and when they might be useful.&lt;/p&gt;
&lt;p&gt;Along the way, you’ll get the chance to make your own namespace package structures, and you’ll &lt;strong&gt;install&lt;/strong&gt; and &lt;strong&gt;extend&lt;/strong&gt; an experimental namespace package from &lt;a href=&quot;https://realpython.com/pypi-publish-python-package/&quot;&gt;PyPI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Python namespace packages are probably going to be useful for people who manage or &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_architecture&quot;&gt;architect&lt;/a&gt; collections of related packages. That said, you’ll get to experiment with a project that can make namespace packages more accessible to the average user.&lt;/p&gt;
&lt;p&gt;This is an advanced tutorial, and to get the most out of it, you should be very familiar with the &lt;a href=&quot;https://realpython.com/tutorials/basics/&quot;&gt;basics&lt;/a&gt; of Python and comfortable with the &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;import&lt;/a&gt; system, as well as having some exposure to &lt;a href=&quot;https://realpython.com/pypi-publish-python-package/&quot;&gt;packaging&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, &lt;strong&gt;what’s a Python namespace package, and what’s it for?&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-namespace-package-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-namespace-package-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free source code&lt;/a&gt; that you’ll use to explore Python namespace packages.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;in-short-python-namespace-packages-are-a-way-to-organize-multiple-packages&quot;&gt;In Short: Python Namespace Packages Are a Way to Organize Multiple Packages&lt;a class=&quot;headerlink&quot; href=&quot;#in-short-python-namespace-packages-are-a-way-to-organize-multiple-packages&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;By way of a quick recap, you’ll first examine the general concept of a Python &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;&lt;strong&gt;namespace&lt;/strong&gt;&lt;/a&gt; before tackling namespace packages. A namespace is a way to group objects under a specific name. You can group values, &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt;, and other objects.&lt;/p&gt;
&lt;p&gt;For example, when you import &lt;code&gt;math&lt;/code&gt;, you gain access to the &lt;code&gt;math&lt;/code&gt; namespace. Inside the &lt;code&gt;math&lt;/code&gt; namespace, you can select from a whole host of different objects.&lt;/p&gt;
&lt;p&gt;You can also think of a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;Python dictionary&lt;/a&gt; as a namespace. With a Python dictionary, you can take two &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; that started out as completely separate, independent variables and include them within the same dictionary namespace:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;real_python&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_page&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://realpython.com&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;import_tutorial&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;python-import&quot;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;real_python&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;home_page&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;home_page&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;real_python&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;import_tutorial&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import_tutorial&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, you can reference both the &lt;code&gt;home_page&lt;/code&gt; and &lt;code&gt;import_tutorial&lt;/code&gt; values from the &lt;code&gt;real_python&lt;/code&gt; namespace. &lt;strong&gt;Namespace packages&lt;/strong&gt; work in a similar way, but they combine whole &lt;a href=&quot;https://realpython.com/python-modules-packages/#python-packages&quot;&gt;packages&lt;/a&gt; instead of values or other Python objects.&lt;/p&gt;
&lt;p&gt;This allows you to have two independent packages on &lt;strong&gt;PyPI&lt;/strong&gt;, for example, that still share the same namespace. One single namespace package doesn’t make a whole lot of sense. To really see the advantage of namespace packages, you need at least two packages.&lt;/p&gt;
&lt;p&gt;Namespace packages are typically used by businesses that may have extensive &lt;strong&gt;libraries&lt;/strong&gt; of packages that they want to keep under a company namespace. For example, the &lt;a href=&quot;https://learn.microsoft.com/en-us/azure/developer/python/sdk/azure-sdk-library-package-index&quot;&gt;Microsoft Azure packages&lt;/a&gt; are all accessible, once installed, through the &lt;code&gt;azure&lt;/code&gt; namespace.&lt;/p&gt;
&lt;p&gt;That’s why you’ll create your own company namespace in the next section.&lt;/p&gt;
&lt;h2 id=&quot;what-does-a-namespace-package-look-like&quot;&gt;What Does a Namespace Package Look Like?&lt;a class=&quot;headerlink&quot; href=&quot;#what-does-a-namespace-package-look-like&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine you work for the Snake Corporation, and your team wants to make sure that all the packages in its library are always accessible from the &lt;code&gt;snake_corp&lt;/code&gt; namespace. So, no matter what package you’re using, as long as it was made by the Snake Corporation, you’ll import from &lt;code&gt;snake_corp&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Without namespace packages, you’d have two options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a &lt;a href=&quot;https://en.wikipedia.org/wiki/Monorepo&quot;&gt;monorepo&lt;/a&gt;, which would be a single package called &lt;code&gt;snake_corp&lt;/code&gt; with hundreds of &lt;a href=&quot;https://realpython.com/python-modules-packages/#python-modules-overview&quot;&gt;modules&lt;/a&gt; for all the different libraries and utilities that you might need.&lt;/li&gt;
&lt;li&gt;Create various packages, but &lt;strong&gt;prefix&lt;/strong&gt; them all with &lt;code&gt;snake_corp&lt;/code&gt;. For example, you might have &lt;code&gt;snake_corp_dateutil&lt;/code&gt; as a package.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The trouble with creating a monorepo is that everyone has to download &lt;em&gt;all&lt;/em&gt; the code even if they only use a tiny fraction of it. It also complicates matters in terms of &lt;strong&gt;version management&lt;/strong&gt; and other packaging workflows, especially if different teams are in charge of different subpackages.&lt;/p&gt;
&lt;p&gt;The issue with creating various packages with a common prefix is that it can be quite verbose, messy, and inelegant. And, at the end of the day, the Snake Corporation CEO has said that they don’t like that solution. They’d prefer using a monorepo over prefixing all the packages. Besides, using common prefixes is just a &lt;strong&gt;convention&lt;/strong&gt; that doesn’t technically create a common namespace.&lt;/p&gt;
&lt;p&gt;What you have in this situation is a perfect use case for namespace packages! Namespace packages allow you to have multiple separate packages with their own packaging workflow, but they can all live in the same &lt;code&gt;snake_corp&lt;/code&gt; namespace.&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; In the following examples, you’ll be creating a bunch of packages. You’ll note that the containing folders and the package names vary depending on whether you’re referring to the name for when you &lt;code&gt;pip install&lt;/code&gt; or import, for example. Check out this table for a rough breakdown of what’s generally used:&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;Purpose&lt;/th&gt;
&lt;th&gt;Typical Casing&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PyPI and &lt;code&gt;pip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Kebab&lt;/td&gt;
&lt;td&gt;&lt;code&gt;charset-normalizer&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Import&lt;/td&gt;
&lt;td&gt;Snake&lt;/td&gt;
&lt;td&gt;&lt;code&gt;charset_normalizer&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prose&lt;/td&gt;
&lt;td&gt;Pascal or none&lt;/td&gt;
&lt;td&gt;Charset Normalizer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;In the following examples, you’ll be using these conventions. But be aware that these conventions aren’t universal.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-namespace-package/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-namespace-package/ »&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 #147: Django Deployment Strategies &amp; Preparing for PyCascades 2023</title>
      <id>https://realpython.com/podcasts/rpp/147/</id>
      <link href="https://realpython.com/podcasts/rpp/147/"/>
      <updated>2023-03-03T12:00:00+00:00</updated>
      <summary>Have you decided how you&#x27;re going to deploy your Django project? Should you use a VPS or a PaaS? Christopher Trudeau is back this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects. We also have organizers from PyCascades to share details about this year&#x27;s hybrid in-person and virtual conference.</summary>
      <content type="html">
        &lt;p&gt;Have you decided how you&#x27;re going to deploy your Django project? Should you use a VPS or a PaaS? Christopher Trudeau is back this week, bringing another batch of PyCoder&#x27;s Weekly articles and projects. We also have organizers from PyCascades to share details about this year&#x27;s hybrid in-person and virtual conference.&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>Iterators and Iterables in Python: Run Efficient Iterations</title>
      <id>https://realpython.com/python-iterators-iterables/</id>
      <link href="https://realpython.com/python-iterators-iterables/"/>
      <updated>2023-03-01T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn what iterators and iterables are in Python. You&#x27;ll learn how they differ and when to use them in your code. You&#x27;ll also learn how to create your own iterators and iterables to make data processing more efficient.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python’s &lt;strong&gt;iterators&lt;/strong&gt; and &lt;strong&gt;iterables&lt;/strong&gt; are two different but related tools that come in handy when you need to iterate over a data stream or container. Iterators power and control the iteration process, while iterables typically hold data that you want to iterate over one value at a time.&lt;/p&gt;
&lt;p&gt;Iterators and iterables are fundamental components of Python programming, and you’ll have to deal with them in almost all your programs. Learning how they work and how to create them is key for you as a Python developer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;strong&gt;iterators&lt;/strong&gt; using the &lt;strong&gt;iterator protocol&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;Understand the &lt;strong&gt;differences&lt;/strong&gt; between iterators and iterables&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Work&lt;/strong&gt; with iterators and iterables in your Python code&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;generator functions&lt;/strong&gt; and the &lt;strong&gt;&lt;code&gt;yield&lt;/code&gt; statement&lt;/strong&gt; to create &lt;strong&gt;generator iterators&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Build your own &lt;strong&gt;iterables&lt;/strong&gt; using different techniques, such as the &lt;strong&gt;iterable protocol&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;asyncio&lt;/code&gt; module and the &lt;code&gt;await&lt;/code&gt; and &lt;code&gt;async&lt;/code&gt; keywords to create &lt;strong&gt;asynchronous iterators&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before diving deeper into these topics, you should be familiar with some core concepts like &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;loops and iteration&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;inheritance&lt;/a&gt;, &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-special-method&quot;&gt;special methods&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/async-io-python/&quot;&gt;asynchronous programming&lt;/a&gt; in Python.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-iterators-iterables-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-iterators-iterables-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the free sample code&lt;/a&gt; that shows you how to use and create iterators and iterables for more efficient data processing.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;understanding-iteration-in-python&quot;&gt;Understanding Iteration in Python&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-iteration-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When writing computer programs, you often need to repeat a given piece of code multiple times. To do this, you can follow one of the following approaches:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Repeating the target code as many times as you need in a sequence&lt;/li&gt;
&lt;li&gt;Putting the target code in a loop that runs as many times as you need&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first approach has a few drawbacks. The most troublesome issue is the repetitive code itself, which is hard to maintain and not scalable. For example, the following code will print a greeting message on your screen three times:&lt;/p&gt;
&lt;div class=&quot;highlight python&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# greeting.py&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!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run this script&lt;/a&gt;, then you’ll get &lt;code&gt;&#x27;Hello!&#x27;&lt;/code&gt; printed on your screen three times. This code works. However, what if you decide to update your code to print &lt;code&gt;&#x27;Hello, World!&#x27;&lt;/code&gt; instead of just &lt;code&gt;&#x27;Hello!&#x27;&lt;/code&gt;? In that case, you’ll have to update the greeting message three times, which is a maintenance burden.&lt;/p&gt;
&lt;p&gt;Now imagine a similar situation but with a larger and more complex piece of code. It can become a nightmare for maintainers.&lt;/p&gt;
&lt;p&gt;Using a loop will be a much better way to solve the problem and avoid the maintainability issue. Loops allow you to run a piece of code as often as you need. Consider how you’d write the above example using a &lt;code&gt;while&lt;/code&gt; loop:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;times&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;times&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;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!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;times&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello!&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello!&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This &lt;code&gt;while&lt;/code&gt; loop runs as long as the loop-continuation condition (&lt;code&gt;times &amp;lt; 3&lt;/code&gt;) remains true. In each iteration, the loop prints your greeting message and increments the control variable, &lt;code&gt;times&lt;/code&gt;. Now, if you decide to update your message, then you just have to modify one line, which makes your code way more maintainable.&lt;/p&gt;
&lt;p&gt;Python’s &lt;code&gt;while&lt;/code&gt; loop supports what’s known as &lt;a href=&quot;https://realpython.com/python-while-loop/&quot;&gt;indefinite iteration&lt;/a&gt;, which means executing the same block of code over and over again, a potentially undefined number of times.&lt;/p&gt;
&lt;p&gt;You’ll also find a different but similar type of iteration known as &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;definite iteration&lt;/a&gt;, which means going through the same code a predefined number of times. This kind of iteration is especially useful when you need to iterate over the items of a data stream one by one in a loop.&lt;/p&gt;
&lt;p&gt;To run an iteration like this, you typically use a &lt;code&gt;for&lt;/code&gt; loop in Python:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, the &lt;code&gt;numbers&lt;/code&gt; &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list&lt;/a&gt; represents your stream of data, which you’ll generically refer to as an &lt;a href=&quot;#getting-to-know-python-iterables&quot;&gt;iterable&lt;/a&gt; because you can iterate over it, as you’ll learn later in this tutorial. The loop goes over each value in &lt;code&gt;numbers&lt;/code&gt; and prints it to your screen.&lt;/p&gt;
&lt;p&gt;When you use a &lt;code&gt;while&lt;/code&gt; or &lt;code&gt;for&lt;/code&gt; loop to repeat a piece of code several times, you’re actually running an &lt;strong&gt;iteration&lt;/strong&gt;. That’s the name given to the process itself.&lt;/p&gt;
&lt;p&gt;In Python, if your iteration process requires going through the values or items in a data collection one item at a time, then you’ll need another piece to complete the puzzle. You’ll need an &lt;strong&gt;iterator&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;getting-to-know-python-iterators&quot;&gt;Getting to Know Python Iterators&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-python-iterators&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Iterators were added to Python &lt;a href=&quot;https://docs.python.org/3/whatsnew/2.2.html#pep-234-iterators&quot;&gt;2.2&lt;/a&gt; through &lt;a href=&quot;https://peps.python.org/pep-0234/&quot;&gt;PEP 234&lt;/a&gt;. They were a significant addition to the language because they unified the iteration process and &lt;a href=&quot;https://en.wikipedia.org/wiki/Abstraction_(computer_science)&quot;&gt;abstracted&lt;/a&gt; it away from the actual implementation of collection or &lt;a href=&quot;https://en.wikipedia.org/wiki/Container_(data_structure)&quot;&gt;container&lt;/a&gt; data types. This abstraction allows iteration over unordered collections, such as sets, ensuring every element is visited exactly once.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-iterators-iterables/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-iterators-iterables/ »&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>Writing Clean, Pythonic Code With namedtuple</title>
      <id>https://realpython.com/courses/python-namedtuple/</id>
      <link href="https://realpython.com/courses/python-namedtuple/"/>
      <updated>2023-02-28T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn what Python&#x27;s namedtuple is and how to use it in your code. You&#x27;ll also learn about the main differences between named tuples and other data structures, such as dictionaries, data classes, and typed named tuples.</summary>
      <content type="html">
        &lt;p&gt;Python&amp;rsquo;s &lt;a href=&quot;https://docs.python.org/3/library/collections.html#module-collections&quot;&gt;&lt;code&gt;collections&lt;/code&gt;&lt;/a&gt; module provides a &lt;a href=&quot;https://en.wikipedia.org/wiki/Factory_(object-oriented_programming)&quot;&gt;factory function&lt;/a&gt; called &lt;a href=&quot;https://docs.python.org/3/library/collections.html#collections.namedtuple&quot;&gt;&lt;code&gt;namedtuple()&lt;/code&gt;&lt;/a&gt;, which is specially designed to make your code more &lt;strong&gt;Pythonic&lt;/strong&gt; when you&amp;rsquo;re working with tuples. With &lt;code&gt;namedtuple()&lt;/code&gt;, you can create &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-immutable&quot;&gt;immutable&lt;/a&gt; sequence types that allow you to access their values using descriptive field names and the &lt;strong&gt;dot notation&lt;/strong&gt; instead of unclear integer indices.&lt;/p&gt;
&lt;p&gt;If you have some experience using Python, then you know that writing Pythonic code is a core skill for Python developers. In this video course, you&amp;rsquo;ll level up that skill using &lt;code&gt;namedtuple&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;code&gt;namedtuple&lt;/code&gt; classes using &lt;strong&gt;&lt;code&gt;namedtuple()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Identify and take advantage of &lt;strong&gt;cool features&lt;/strong&gt; of &lt;code&gt;namedtuple&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;namedtuple&lt;/code&gt; instances to write &lt;strong&gt;Pythonic code&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Decide whether to use a &lt;code&gt;namedtuple&lt;/code&gt; or a &lt;strong&gt;similar data structure&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Subclass&lt;/strong&gt; a &lt;code&gt;namedtuple&lt;/code&gt; to provide new features&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this course, you need to have a general understanding of Python&amp;rsquo;s philosophy related to &lt;a href=&quot;https://realpython.com/learning-paths/writing-pythonic-code/&quot;&gt;writing Pythonic and readable code&lt;/a&gt;. You also need to know the basics of working with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;Tuples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;Dictionaries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;Classes and object-oriented programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-data-classes/&quot;&gt;Data classes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you don&amp;rsquo;t have all the required knowledge before starting this video course, then that&amp;rsquo;s okay! You can stop and review the above resources as needed.&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 NumPy reshape() to Change the Shape of an Array</title>
      <id>https://realpython.com/numpy-reshape/</id>
      <link href="https://realpython.com/numpy-reshape/"/>
      <updated>2023-02-27T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use NumPy reshape() to rearrange the data in an array. You&#x27;ll learn to increase and decrease the number of dimensions and to configure the data in the new array to suit your requirements.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The main data structure that you’ll use in &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy&lt;/a&gt; is the &lt;a href=&quot;https://numpy.org/doc/stable/reference/arrays.ndarray.html&quot;&gt;N-dimensional array&lt;/a&gt;. An array can have one or more dimensions to structure your data. In some programs, you may need to change how you organize your data within a NumPy array. You can use NumPy’s &lt;strong&gt;&lt;code&gt;reshape()&lt;/code&gt;&lt;/strong&gt; to rearrange the data.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://numpy.org/doc/stable/glossary.html#term-shape&quot;&gt;shape&lt;/a&gt; of an array describes the number of dimensions in the array and the length of each dimension. In this tutorial, you’ll learn how to change the shape of a NumPy array to place all its data in a different configuration. When you complete this tutorial, you’ll be able to alter the shape of any array to suit your application’s needs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Change the shape&lt;/strong&gt; of a NumPy array without changing its number of dimensions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add and remove dimensions&lt;/strong&gt; in a NumPy array&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Control how data is rearranged&lt;/strong&gt; when reshaping an array with the &lt;code&gt;order&lt;/code&gt; parameter&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use a wildcard value&lt;/strong&gt; of &lt;code&gt;-1&lt;/code&gt; for one of the dimensions in &lt;code&gt;reshape()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this tutorial, you should be familiar with the basics of NumPy and N-dimensional arrays. You can read &lt;a href=&quot;https://realpython.com/numpy-tutorial/&quot;&gt;NumPy Tutorial: Your First Steps Into Data Science in Python&lt;/a&gt; to learn more about NumPy before diving in.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Supplemental Material:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/numpy-reshape-repository/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-numpy-reshape-repository&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the image repository&lt;/a&gt; that you’ll use with NumPy &lt;code&gt;reshape()&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;install-numpy&quot;&gt;Install NumPy&lt;a class=&quot;headerlink&quot; href=&quot;#install-numpy&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You’ll need to install NumPy to your environment to run the code in this tutorial and explore &lt;code&gt;reshape()&lt;/code&gt;. You can install the package using &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt; within a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;virtual environment&lt;/a&gt;. Select either the Windows or Linux + macOS tab below to see instructions for your operating system:&lt;/p&gt;
&lt;ul class=&quot;nav nav-tabs justify-content-end js-platform-widget-tabs&quot; role=&quot;tablist&quot;&gt;

  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-windows&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body active small&quot; id=&quot;windows-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#windows-1&quot; role=&quot;tab&quot; aria-controls=&quot;windows-1&quot; aria-selected=&quot;true&quot;&gt;&lt;i class=&quot;fa fa-windows text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;Windows&lt;/a&gt;
  &lt;/li&gt;




  &lt;li class=&quot;nav-item mb-0 js-platform-widget-tab-linuxmacos&quot; role=&quot;presentation&quot;&gt;
    &lt;a class=&quot;nav-link link-unstyled text-body small&quot; id=&quot;macos-tab-1&quot; data-toggle=&quot;tab&quot; href=&quot;#linux-macos-1&quot; role=&quot;tab&quot; aria-controls=&quot;linux-macos-1&quot; aria-selected=&quot;false&quot;&gt;&lt;i class=&quot;fa fa-linux text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;&lt;i class=&quot;fa fa-apple text-muted mr-1&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;Linux + macOS&lt;/a&gt;
  &lt;/li&gt;

&lt;/ul&gt;
&lt;div class=&quot;tab-content mt-2 mb-0 js-platform-widget-content&quot;&gt;
&lt;div aria-labelledby=&quot;windows-tab-1&quot; class=&quot;tab-pane fade show active&quot; id=&quot;windows-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;highlight pscon&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;PS&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;python&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;PS&amp;gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;venv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Scripts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;activate&lt;/span&gt;
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;PS&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;python&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pip&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div aria-labelledby=&quot;linux-macos-tab-1&quot; class=&quot;tab-pane fade &quot; id=&quot;linux-macos-1&quot; role=&quot;tabpanel&quot;&gt;
&lt;div class=&quot;highlight sh&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 -m venv venv
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; venv/bin/activate
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python -m pip install numpy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It’s a convention to use the alias &lt;code&gt;np&lt;/code&gt; when you import NumPy. To get started, you can import NumPy in the &lt;a href=&quot;https://realpython.com/python-repl/&quot;&gt;Python REPL&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;np&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now that you’ve installed NumPy and imported the package in a REPL environment, you’re ready to start working with NumPy arrays.  &lt;/p&gt;
&lt;h2 id=&quot;understand-the-shape-of-numpy-arrays&quot;&gt;Understand the Shape of NumPy Arrays&lt;a class=&quot;headerlink&quot; href=&quot;#understand-the-shape-of-numpy-arrays&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You’ll use NumPy’s &lt;a href=&quot;https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html&quot;&gt;&lt;code&gt;ndarray&lt;/code&gt;&lt;/a&gt;  in this tutorial. In this section, you’ll review the key features of this data structure, including an array’s overall &lt;a href=&quot;https://numpy.org/doc/stable/glossary.html#term-shape&quot;&gt;shape&lt;/a&gt; and number of &lt;a href=&quot;https://numpy.org/doc/stable/glossary.html#term-axis&quot;&gt;dimensions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can create an array from a list of lists:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]])&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([[1, 2, 3, 4],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;       [5, 6, 7, 8]])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The function &lt;a href=&quot;https://numpy.org/doc/stable/reference/generated/numpy.array.html&quot;&gt;&lt;code&gt;np.array()&lt;/code&gt;&lt;/a&gt; returns an object of type &lt;a href=&quot;https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html&quot;&gt;&lt;code&gt;np.ndarray&lt;/code&gt;&lt;/a&gt;. This data structure is the main data type in NumPy.&lt;/p&gt;
&lt;p&gt;You can describe the shape of an array using the length of each dimension of the array. NumPy represents this as a tuple of integers. The array &lt;code&gt;numbers&lt;/code&gt; has two rows and four columns. Therefore, this array has a &lt;code&gt;(2, 4)&lt;/code&gt; shape:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;n&quot;&gt;shape&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;(2, 4)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can represent the same data using a different shape:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/numpy-reshape-24-42.679add5e8d11.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/numpy-reshape-24-42.679add5e8d11.png&quot; width=&quot;800&quot; height=&quot;800&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/numpy-reshape-24-42.679add5e8d11.png&amp;amp;w=200&amp;amp;sig=fe6792f8865ca498a6b77f2d8d48bd9d5e6b9837 200w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/numpy-reshape-24-42.679add5e8d11.png&amp;amp;w=266&amp;amp;sig=9779c6c91acaa0b8f6226c76e8a43b489ee1b2e5 266w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/numpy-reshape-24-42.679add5e8d11.png&amp;amp;w=400&amp;amp;sig=9b7ffac39d35910b9ad305fdfa5c40a803f2955a 400w, https://files.realpython.com/media/numpy-reshape-24-42.679add5e8d11.png 800w&quot; sizes=&quot;(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)&quot; alt=&quot;Visual representation of NumPy arrays with different shapes&quot; data-asset=&quot;4894&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Both of these arrays contain the same data. The array with the shape &lt;code&gt;(2, 4)&lt;/code&gt; has two rows and four columns and the array with the shape &lt;code&gt;(4, 2)&lt;/code&gt; has four rows and two columns. You can check the number of dimensions of an array using &lt;code&gt;.ndim&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&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;n&quot;&gt;ndim&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The array &lt;code&gt;numbers&lt;/code&gt; is two-dimensional (2D). You can arrange the same data contained in &lt;code&gt;numbers&lt;/code&gt; in arrays with a different number of dimensions:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/numpy-reshape/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/numpy-reshape/ »&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 #146: Using NumPy and Linear Algebra for Faster Python Code</title>
      <id>https://realpython.com/podcasts/rpp/146/</id>
      <link href="https://realpython.com/podcasts/rpp/146/"/>
      <updated>2023-02-24T12:00:00+00:00</updated>
      <summary>Are you still using loops and lists to process your data in Python? Have you heard of a Python library with optimized data structures and built-in operations that can speed up your data science code? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to share secrets for harnessing linear algebra and NumPy for your projects.</summary>
      <content type="html">
        &lt;p&gt;Are you still using loops and lists to process your data in Python? Have you heard of a Python library with optimized data structures and built-in operations that can speed up your data science code? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to share secrets for harnessing linear algebra and NumPy for your projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Using the Terminal on Windows</title>
      <id>https://realpython.com/courses/using-terminal-windows/</id>
      <link href="https://realpython.com/courses/using-terminal-windows/"/>
      <updated>2023-02-21T14:00:00+00:00</updated>
      <summary>In this Code Conversation video course, you&#x27;ll learn how to use the terminal on Windows.
You&#x27;ll navigate the file system with Philipp and Ian and perform common tasks like creating files and folders. If you&#x27;ve never used the terminal before, then this video course will help you get started.</summary>
      <content type="html">
        &lt;p&gt;The &lt;strong&gt;terminal&lt;/strong&gt; can be intimidating to work with when you&amp;rsquo;re used to working with graphical user interfaces. However, it&amp;rsquo;s an important tool that you need to get used to in your journey as a Python developer.
Even though you can substitute some workflows in the terminal with apps that contain a graphical user interface (GUI), you may need to open the terminal at some point in your life as a Python developer.&lt;/p&gt;
&lt;p&gt;In this &lt;strong&gt;Code Conversation&lt;/strong&gt;, you&amp;rsquo;ll follow a chat between Philipp and Ian as they perform common tasks in the terminal on Windows, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Showing the current working directory&lt;/li&gt;
&lt;li&gt;Listing the contents of a folder&lt;/li&gt;
&lt;li&gt;Adding text to files without opening them&lt;/li&gt;
&lt;li&gt;Displaying the content of a file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Along the way, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Find the terminal&lt;/strong&gt; on your operating system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open the terminal&lt;/strong&gt; for the first time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Navigate your file system&lt;/strong&gt; with basic commands&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create files and folders&lt;/strong&gt; with the terminal&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Run Python files&lt;/strong&gt; on Windows&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;ve never worked with the terminal on Windows before or you want to see some interesting use cases to incorporate the terminal into your workflow, then this video course is the perfect start for you.&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 #145: Creating a Python Wordle Clone &amp; Testing Environments With Nox</title>
      <id>https://realpython.com/podcasts/rpp/145/</id>
      <link href="https://realpython.com/podcasts/rpp/145/"/>
      <updated>2023-02-17T12:00:00+00:00</updated>
      <summary>Would you like to practice your Python skills while building a challenging word game? Have you been wanting to learn more about creating command-line interfaces and  making them colorful and interactive? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Would you like to practice your Python skills while building a challenging word game? Have you been wanting to learn more about creating command-line interfaces and  making them colorful and interactive? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Getters and Setters in Python</title>
      <id>https://realpython.com/courses/getters-and-setters-python/</id>
      <link href="https://realpython.com/courses/getters-and-setters-python/"/>
      <updated>2023-02-14T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn what getter and setter methods are, how Python properties are preferred over getters and setters when dealing with attribute access and mutation, and when to use getter and setter methods instead of properties in Python.</summary>
      <content type="html">
        &lt;p&gt;If you come from a language like &lt;a href=&quot;https://realpython.com/java-vs-python/&quot;&gt;Java&lt;/a&gt; or &lt;a href=&quot;https://realpython.com/python-vs-cpp/&quot;&gt;C++&lt;/a&gt;, then you&amp;rsquo;re probably used to writing &lt;strong&gt;getter&lt;/strong&gt; and &lt;strong&gt;setter&lt;/strong&gt; methods for every attribute in your classes. These methods allow you to access and mutate private attributes while maintaining &lt;strong&gt;encapsulation&lt;/strong&gt;. In Python, you&amp;rsquo;ll typically expose attributes as part of your public API and use &lt;strong&gt;properties&lt;/strong&gt; when you need attributes with functional behavior.&lt;/p&gt;
&lt;p&gt;Even though properties are the Pythonic way to go, they can have some practical drawbacks. Because of this, you&amp;rsquo;ll find some situations where getters and setters are preferable over properties.&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;Write &lt;strong&gt;getter&lt;/strong&gt; and &lt;strong&gt;setter&lt;/strong&gt; methods in your classes&lt;/li&gt;
&lt;li&gt;Replace getter and setter methods with &lt;strong&gt;properties&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Explore &lt;strong&gt;other tools&lt;/strong&gt; to replace getter and setter methods in Python&lt;/li&gt;
&lt;li&gt;Decide when &lt;strong&gt;setter&lt;/strong&gt; and &lt;strong&gt;getter&lt;/strong&gt; methods can be the &lt;strong&gt;right tool for the job&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get the most out of this course, you should be familiar with Python &lt;a href=&quot;https://realpython.com/courses/intro-object-oriented-programming-oop-python/&quot;&gt;object-oriented&lt;/a&gt; programming. It&amp;rsquo;ll also be a plus if you have basic knowledge of Python &lt;a href=&quot;https://realpython.com/courses/property-python/&quot;&gt;properties&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-descriptors/&quot;&gt;descriptors&lt;/a&gt;.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #144: Wrangling Business Process Models With Python and SpiffWorkflow</title>
      <id>https://realpython.com/podcasts/rpp/144/</id>
      <link href="https://realpython.com/podcasts/rpp/144/"/>
      <updated>2023-02-10T12:00:00+00:00</updated>
      <summary>Can you describe your business processes with flowcharts? What if you could define the steps in a standard notation and implement the workflows in pure Python? This week on the show, Dan Funk from Sartography is here to discuss SpiffWorkflow.</summary>
      <content type="html">
        &lt;p&gt;Can you describe your business processes with flowcharts? What if you could define the steps in a standard notation and implement the workflows in pure Python? This week on the show, Dan Funk from Sartography is here to discuss SpiffWorkflow.&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 Basics: Building Systems With Classes</title>
      <id>https://realpython.com/courses/python-basics-class/</id>
      <link href="https://realpython.com/courses/python-basics-class/"/>
      <updated>2023-02-07T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to work with classes to build complex systems in Python. By composing classes, inheriting from other classes, and overriding class behavior, you&#x27;ll harness the power of object-oriented programming (OOP).</summary>
      <content type="html">
        &lt;p&gt;In the &lt;a href=&quot;https://realpython.com/courses/python-basics-oop/&quot;&gt;previous course&lt;/a&gt; in the &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics&lt;/a&gt; series, you learned how to use classes to create new objects. Now that you understand the basics of object-oriented programming (OOP), it&amp;rsquo;s time to put those classes to work.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Compose&lt;/strong&gt; classes together to create layers of functionality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inherit&lt;/strong&gt; and &lt;strong&gt;override&lt;/strong&gt; behavior from other classes to create variations&lt;/li&gt;
&lt;li&gt;Creatively &lt;strong&gt;mix&lt;/strong&gt; and &lt;strong&gt;match&lt;/strong&gt; these approaches&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With these capabilities, you&amp;rsquo;ll be able to build more complex systems and write readable, reusable code.&lt;/p&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course. If you&amp;rsquo;re just getting started, then you might want to check out &lt;a href=&quot;https://realpython.com/courses/setting-up-python/&quot;&gt;Python Basics: Setting Up Python&lt;/a&gt; before diving into this course.&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 #143: Create Interactive Maps &amp; Geospatial Data Visualizations With Python</title>
      <id>https://realpython.com/podcasts/rpp/143/</id>
      <link href="https://realpython.com/podcasts/rpp/143/"/>
      <updated>2023-02-03T12:00:00+00:00</updated>
      <summary>Would you like to quickly add data to a map with Python? Have you wanted to create beautiful interactive maps and export them as a stand-alone static web page? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Would you like to quickly add data to a map with Python? Have you wanted to create beautiful interactive maps and export them as a stand-alone static web page? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Using the Terminal on Linux</title>
      <id>https://realpython.com/courses/using-terminal-linux/</id>
      <link href="https://realpython.com/courses/using-terminal-linux/"/>
      <updated>2023-01-31T14:00:00+00:00</updated>
      <summary>In this Code Conversation video course, you&#x27;ll learn how to use the terminal on Linux.
You&#x27;ll navigate the file system with Philipp and Geir Arne and perform common tasks like creating files and folders. If you&#x27;ve never used the terminal before, then this video course will help you get started.</summary>
      <content type="html">
        &lt;p&gt;The &lt;strong&gt;terminal&lt;/strong&gt; can be intimidating to work with when you&amp;rsquo;re used to working with graphical user interfaces. However, it&amp;rsquo;s an important tool that you need to get used to in your journey as a Python developer.
Even though you can substitute some workflows in the terminal with apps that contain a graphical user interface (GUI), you may need to open the terminal at some point in your life as a Python developer.&lt;/p&gt;
&lt;p&gt;In this &lt;strong&gt;Code Conversation&lt;/strong&gt;, you&amp;rsquo;ll follow a chat between Philipp and Geir Arne as they perform common tasks in the terminal on Linux, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Showing the current working directory&lt;/li&gt;
&lt;li&gt;Listing the contents of a folder&lt;/li&gt;
&lt;li&gt;Adding text to files without opening them&lt;/li&gt;
&lt;li&gt;Displaying the content of a file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Along the way, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Find the terminal&lt;/strong&gt; on your operating system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open the terminal&lt;/strong&gt; for the first time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Navigate your file system&lt;/strong&gt; with basic commands&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create files and folders&lt;/strong&gt; with the terminal&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Run Python files&lt;/strong&gt; on Linux&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;ve never worked with the terminal on Linux before or you want to see some interesting use cases to incorporate the terminal into your workflow, then this video course is the perfect start for you.&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 #142: Orchestrating Large and Small Projects With Apache Airflow</title>
      <id>https://realpython.com/podcasts/rpp/142/</id>
      <link href="https://realpython.com/podcasts/rpp/142/"/>
      <updated>2023-01-27T12:00:00+00:00</updated>
      <summary>Have you worked on a project that needed an orchestration tool? How do you define the workflow of an entire data pipeline or a messaging system with Python? This week on the show, Calvin Hendryx-Parker is back to talk about using Apache Airflow and orchestrating Python projects.</summary>
      <content type="html">
        &lt;p&gt;Have you worked on a project that needed an orchestration tool? How do you define the workflow of an entire data pipeline or a messaging system with Python? This week on the show, Calvin Hendryx-Parker is back to talk about using Apache Airflow and orchestrating Python projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Object-Oriented Programming</title>
      <id>https://realpython.com/courses/python-basics-oop/</id>
      <link href="https://realpython.com/courses/python-basics-oop/"/>
      <updated>2023-01-24T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll get to know OOP, or object-oriented programming. You&#x27;ll learn how to create a class, use classes to create new objects, and instantiate classes with attributes.</summary>
      <content type="html">
        &lt;p&gt;&lt;strong&gt;OOP&lt;/strong&gt;, or &lt;strong&gt;object-oriented programming&lt;/strong&gt;, is a method of structuring a program by bundling related properties and behaviors into individual objects. &lt;/p&gt;
&lt;p&gt;Conceptually, objects are like the components of a system. Think of a program as a factory assembly line of sorts. At each step of the assembly line, a system component processes some material, ultimately transforming raw material into a finished product.&lt;/p&gt;
&lt;p&gt;An object contains both data, like the raw or preprocessed materials at each step on an assembly line, and behavior, like the action that each assembly line component performs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;strong&gt;&lt;code&gt;class&lt;/code&gt;&lt;/strong&gt;, which is like a blueprint for creating an object&lt;/li&gt;
&lt;li&gt;Use classes to create new &lt;strong&gt;objects&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Instantiate classes with &lt;strong&gt;attributes&lt;/strong&gt; and &lt;strong&gt;methods&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This video course is part of the Python Basics series, which accompanies &lt;a href=&quot;https://realpython.com/products/python-basics-book/&quot;&gt;&lt;em&gt;Python Basics: A Practical Introduction to Python 3&lt;/em&gt;&lt;/a&gt;. You can also check out the other &lt;a href=&quot;https://realpython.com/learning-paths/python-basics/&quot;&gt;Python Basics courses&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Note that you&amp;rsquo;ll be using &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; to &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interact with Python&lt;/a&gt; throughout this course. If you&amp;rsquo;re just getting started, then you might want to check out &lt;a href=&quot;https://realpython.com/courses/setting-up-python/&quot;&gt;Python Basics: Setting Up Python&lt;/a&gt; before diving into this course.&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>
