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

  
    <entry>
      <title>The Real Python Podcast – Episode #104: Building a Hash Table in Python and Thoughtful REST API Design</title>
      <id>https://realpython.com/podcasts/rpp/104/</id>
      <link href="https://realpython.com/podcasts/rpp/104/"/>
      <updated>2022-04-01T12:00:00+00:00</updated>
      <summary>Do you understand how a hash table works? What if you could learn about building one while practicing test-driven development? What are best practices when designing a REST API? This week on the show, Christopher Trudeau is here, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Do you understand how a hash table works? What if you could learn about building one while practicing test-driven development? What are best practices when designing a REST API? This week on the show, Christopher Trudeau is here, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python GUI Programming With Tkinter</title>
      <id>https://realpython.com/python-gui-tkinter/</id>
      <link href="https://realpython.com/python-gui-tkinter/"/>
      <updated>2022-03-30T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn the basics of GUI programming with Tkinter, the de facto Python GUI framework. Master GUI programming concepts such as widgets, geometry managers, and event handlers. Then, put it all together by building two applications: a temperature converter and a text editor.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python has a lot of &lt;a href=&quot;http://wiki.python.org/moin/GuiProgramming&quot;&gt;GUI frameworks&lt;/a&gt;, but &lt;a href=&quot;https://wiki.python.org/moin/TkInter&quot;&gt;Tkinter&lt;/a&gt; is the only framework that’s built into the Python standard library. Tkinter has several strengths. It’s &lt;strong&gt;cross-platform&lt;/strong&gt;, so the same code works on Windows, macOS, and Linux. Visual elements are rendered using native operating system elements, so applications built with Tkinter look like they belong on the platform where they’re run.&lt;/p&gt;
&lt;p&gt;Although Tkinter is considered the de facto Python GUI framework, it’s not without criticism. One notable criticism is that GUIs built with Tkinter look outdated. If you want a shiny, modern interface, then Tkinter may not be what you’re looking for.&lt;/p&gt;
&lt;p&gt;However, Tkinter is lightweight and relatively painless to use compared to other frameworks. This makes it a compelling choice for building GUI applications in Python, especially for applications where a modern sheen is unnecessary, and the top priority is to quickly build something that’s functional and cross-platform.&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;Get started with Tkinter with a &lt;strong&gt;Hello, World&lt;/strong&gt; application&lt;/li&gt;
&lt;li&gt;Work with &lt;strong&gt;widgets&lt;/strong&gt;, such as buttons and text boxes&lt;/li&gt;
&lt;li&gt;Control your application layout with &lt;strong&gt;geometry managers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Make your applications &lt;strong&gt;interactive&lt;/strong&gt; by associating button clicks with Python functions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you’ve mastered these skills by working through the exercises at the end of each section, you’ll tie everything together by building two applications. The first is a &lt;strong&gt;temperature converter&lt;/strong&gt;, and the second is a &lt;strong&gt;text editor&lt;/strong&gt;. It’s time to dive right in and learn how to build an application with Tkinter!&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; This tutorial is adapted from the chapter “Graphical User Interfaces” of &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;The book uses Python’s built-in &lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;IDLE&lt;/a&gt; editor to create and edit Python files and interact with the Python shell. In this tutorial, references to IDLE have been removed in favor of more general language.&lt;/p&gt;
&lt;p&gt;The bulk of the material in this tutorial has been left unchanged, and you should have no problems running the example code from the editor and environment of your choice.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-mastery-course/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-mastery-course&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;5 Thoughts On Python Mastery&lt;/a&gt;, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;building-your-first-python-gui-application-with-tkinter&quot;&gt;Building Your First Python GUI Application With Tkinter&lt;a class=&quot;headerlink&quot; href=&quot;#building-your-first-python-gui-application-with-tkinter&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The foundational element of a Tkinter GUI is the &lt;strong&gt;window&lt;/strong&gt;. Windows are the containers in which all other GUI elements live. These other GUI elements, such as text boxes, labels, and buttons, are known as &lt;strong&gt;widgets&lt;/strong&gt;. Widgets are contained inside of windows.&lt;/p&gt;
&lt;p&gt;First, create a window that contains a single widget. Start up a new &lt;a href=&quot;https://realpython.com/interacting-with-python/#using-the-python-interpreter-interactively&quot;&gt;Python shell&lt;/a&gt; session and follow along!&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 code examples in this tutorial have all been tested on Windows, macOS, and Ubuntu Linux 20.04 with Python version 3.10.&lt;/p&gt;
&lt;p&gt;If you’ve &lt;a href=&quot;https://realpython.com/installing-python/&quot;&gt;installed Python&lt;/a&gt; with the official installers available for &lt;a href=&quot;https://www.python.org/downloads/windows/&quot;&gt;Windows&lt;/a&gt; and &lt;a href=&quot;https://www.python.org/downloads/mac-osx/&quot;&gt;macOS&lt;/a&gt; from &lt;a href=&quot;https://python.org&quot;&gt;python.org&lt;/a&gt;, then you should have no problem running the sample code. You can safely skip the rest of this note and continue with the tutorial!&lt;/p&gt;
&lt;p&gt;If you haven’t installed Python with the official installers, or there’s no official distribution for your system, then here are some tips for getting up and going.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Python on macOS with Homebrew:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The Python distribution for macOS available on &lt;a href=&quot;https://github.com/Homebrew/homebrew-core/pull/34424&quot;&gt;Homebrew&lt;/a&gt; doesn’t come bundled with the &lt;a href=&quot;https://www.tcl.tk/&quot;&gt;Tcl/Tk&lt;/a&gt; dependency required by Tkinter. The default system version is used instead. This version may be outdated and prevent you from importing the Tkinter module. To avoid this problem, use the &lt;a href=&quot;https://www.python.org/downloads/mac-osx/&quot;&gt;official macOS installer&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ubuntu Linux 20.04:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To conserve memory space, the default version of the Python interpreter that comes pre-installed on Ubuntu Linux 20.04 has no support for Tkinter. However, if you want to continue using the Python interpreter bundled with your operating system, then install the following package:&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;sudo apt-get install python3-tk
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This installs the Python GUI Tkinter module.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Other Linux Flavors:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you’re unable to get a working Python installation on your flavor of Linux, then you can build Python with the correct version of Tcl/Tk from the source code. For a step-by-step walk-through of this process, check out the &lt;a href=&quot;https://realpython.com/installing-python/#compiling-python-from-source&quot;&gt;Python 3 Installation &amp;amp; Setup Guide&lt;/a&gt;. You may also try using &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;pyenv&lt;/a&gt; to manage multiple Python versions.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;With your Python shell open, the first thing you need to do is import the Python GUI Tkinter 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;tkinter&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tk&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A &lt;strong&gt;window&lt;/strong&gt; is an instance of Tkinter’s &lt;code&gt;Tk&lt;/code&gt; class. Go ahead and create a new window and assign it to the &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variable&lt;/a&gt; &lt;code&gt;window&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;window&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tk&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;When you execute the above code, a new window pops up on your screen. How it looks depends on your operating system:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/17_4_tk_window.662fec42e4f9.jpg&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/17_4_tk_window.662fec42e4f9.jpg&quot; width=&quot;853&quot; height=&quot;337&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/17_4_tk_window.662fec42e4f9.jpg&amp;amp;w=213&amp;amp;sig=e7e4421c507bdbe02c31b21b50fb1aee57d81dc3 213w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/17_4_tk_window.662fec42e4f9.jpg&amp;amp;w=426&amp;amp;sig=0eb3323d103418371c05cbb1f6bd01ff0e77fb2c 426w, https://files.realpython.com/media/17_4_tk_window.662fec42e4f9.jpg 853w&quot; sizes=&quot;75vw&quot; alt=&quot;A blank Tkinter application window on Windows 10, macOS, and Ubuntu Linux&quot; data-asset=&quot;2147&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Throughout the rest of this tutorial, you’ll see Windows screenshots.&lt;/p&gt;
&lt;h3 id=&quot;adding-a-widget&quot;&gt;Adding a Widget&lt;a class=&quot;headerlink&quot; href=&quot;#adding-a-widget&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Now that you have a window, you can add a widget. Use the &lt;code&gt;tk.Label&lt;/code&gt; class to add some text to a window. Create a &lt;code&gt;Label&lt;/code&gt; widget with the text &lt;code&gt;&quot;Hello, Tkinter&quot;&lt;/code&gt; and assign it to a variable called &lt;code&gt;greeting&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;greeting&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tk&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello, Tkinter&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 window you created earlier doesn’t change. You just created a &lt;code&gt;Label&lt;/code&gt; widget, but you haven’t added it to the window yet. There are several ways to add widgets to a window. Right now, you can use the &lt;code&gt;Label&lt;/code&gt; widget’s &lt;code&gt;.pack()&lt;/code&gt; method:&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;greeting&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pack&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 window now looks like this:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-gui-tkinter/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-gui-tkinter/ »&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>Using Python&#x27;s datetime Module</title>
      <id>https://realpython.com/courses/python-datetime-module/</id>
      <link href="https://realpython.com/courses/python-datetime-module/"/>
      <updated>2022-03-29T14:00:00+00:00</updated>
      <summary>Have you ever wondered about working with dates and times in Python? In this video course, you&#x27;ll learn all about the built-in Python datetime library. You&#x27;ll also learn about how to manage time zones and daylight saving time, and how to do accurate arithmetic on dates and times.</summary>
      <content type="html">
        &lt;p&gt;Python has several different modules to deal with dates and times. This course concentrates on the primary one, &lt;strong&gt;&lt;code&gt;datetime&lt;/code&gt;&lt;/strong&gt;. Dates and times are messy things! Shifts due to daylight savings time and time zones complicate any computing with dates and times. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll tackle that messiness and learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to use the &lt;strong&gt;&lt;code&gt;datetime&lt;/code&gt;&lt;/strong&gt; module&lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;&lt;code&gt;zoneinfo&lt;/code&gt;&lt;/strong&gt; module does and how to use it&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;calculate the difference&lt;/strong&gt; between two &lt;code&gt;datetime&lt;/code&gt; objects&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Pagination for a User-Friendly Django App</title>
      <id>https://realpython.com/django-pagination/</id>
      <link href="https://realpython.com/django-pagination/"/>
      <updated>2022-03-28T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to serve paginated content in your Django apps. Using Django pagination can significantly improve your website&#x27;s performance and give your visitors a better user experience.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You can improve the user experience of your Django web app significantly by spreading your content over multiple pages instead of serving all of it at once.
This practice is called &lt;strong&gt;pagination&lt;/strong&gt;.
To implement pagination, you have to consider page count, items per page, and the order of pages.&lt;/p&gt;
&lt;p&gt;But if you’re using Django for your web projects, you’re in luck!
Django has the pagination functionality built in.
With only a few configuration steps, you can provide paginated content to your users.&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;Decide when to use &lt;strong&gt;Django’s paginator&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implement pagination in &lt;strong&gt;class-based views&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implement pagination in &lt;strong&gt;function-based views&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;pagination elements&lt;/strong&gt; to templates&lt;/li&gt;
&lt;li&gt;Browse pages directly with &lt;strong&gt;paginated URLs&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Combine Django pagination with &lt;strong&gt;JavaScript calls&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This tutorial is for intermediate Python programmers with basic Django experience.
Ideally, you’ve completed some introductory tutorials or created your own smaller Django projects.
To have the best experience with this tutorial, you should know what models, views, and templates are and how to create them.
If you need a refresher, then check out the tutorial on how to &lt;a href=&quot;https://realpython.com/get-started-with-django-1/&quot;&gt;build a portfolio app with Django&lt;/a&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;Get Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/django-pagination-source-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-django-pagination-source-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get the source code&lt;/a&gt; that you’ll use to implement Django pagination.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;pagination-in-the-wild&quot;&gt;Pagination in the Wild&lt;a class=&quot;headerlink&quot; href=&quot;#pagination-in-the-wild&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before you try your hand at building your own pagination flows with Django, it’s worth looking around to spot pagination in action.
Pagination is so common on bigger websites that you’ve most likely experienced it in one form or another when browsing the Internet.&lt;/p&gt;
&lt;h3 id=&quot;what-pagination-is&quot;&gt;What Pagination Is&lt;a class=&quot;headerlink&quot; href=&quot;#what-pagination-is&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Pagination describes the practice of distributing your website’s content across multiple consecutive pages instead of serving it on a single page.
If you visit shopping sites, blogs, or archives, you’re likely to encounter paginated content.&lt;/p&gt;
&lt;p&gt;On &lt;a href=&quot;https://realpython.com/python-git-github-intro/&quot;&gt;GitHub&lt;/a&gt;, you’ll find paginated content on &lt;a href=&quot;https://github.com/django/django/pulls?q=&quot;&gt;Django’s pull requests&lt;/a&gt; page.
When you reach the bottom of the page, you can navigate to other pages:&lt;/p&gt;
&lt;figure class=&quot;&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block border w-66&quot; src=&quot;https://files.realpython.com/media/django-pagination-example-github.efcada685a44.png&quot; width=&quot;968&quot; height=&quot;116&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination-example-github.efcada685a44.png&amp;amp;w=242&amp;amp;sig=b5c73ec837c9b04154e29e3b4bc64dfce62cc763 242w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination-example-github.efcada685a44.png&amp;amp;w=484&amp;amp;sig=da21e32e3a08abc01d31d50a1497808d2a038c5a 484w, https://files.realpython.com/media/django-pagination-example-github.efcada685a44.png 968w&quot; sizes=&quot;75vw&quot; alt=&quot;Pagination Example: GitHub&quot; data-asset=&quot;4208&quot;&gt;&lt;/figure&gt;

&lt;p&gt;Imagine how crowded the bottom of the page would be if all the page numbers were displayed.
What’s more, consider how long the page would take to load if all the issues were displayed at once instead of being spread over 615 pages.&lt;/p&gt;
&lt;p&gt;You could even argue that having page numbers is unnecessary.
How could anybody know which issue is on which page?
For that reason, some sites ditch page numbers entirely and give you a condensed form of pagination.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://pycoders.com/&quot;&gt;PyCoder’s Weekly Newsletter&lt;/a&gt; paginates its archive with &lt;em&gt;Previous&lt;/em&gt; and &lt;em&gt;Next&lt;/em&gt; buttons.
This type of pagination lets you conveniently browse through all newsletter issues:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/django-pagination_example_pycoders-weekly.8ade2116237d.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/django-pagination_example_pycoders-weekly.8ade2116237d.png&quot; width=&quot;1920&quot; height=&quot;1080&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination_example_pycoders-weekly.8ade2116237d.png&amp;amp;w=480&amp;amp;sig=e70ab9c20e201b886d9006609af869cc20be8d5b 480w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination_example_pycoders-weekly.8ade2116237d.png&amp;amp;w=960&amp;amp;sig=488753ae5e40025e92b74796f3130cb4957bc26f 960w, https://files.realpython.com/media/django-pagination_example_pycoders-weekly.8ade2116237d.png 1920w&quot; sizes=&quot;75vw&quot; alt=&quot;Pagination Example: PyCoders Weekly&quot; data-asset=&quot;4206&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Underneath the &lt;em&gt;Subscribe&lt;/em&gt; button, you see the pagination controls for navigating to the previous and next issues.
Thanks to this pagination technique, you’re able hop from one newsletter issue to another instead of selecting issues from the archive one by one.&lt;/p&gt;
&lt;p&gt;You can also see pagination in action when you’ve got more than one hundred objects in your &lt;a href=&quot;https://realpython.com/customize-django-admin-python/&quot;&gt;Django admin&lt;/a&gt; interface.
To access more content, you have to click another page number:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/django-pagination_example_django-admin.8ab6cabab559.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/django-pagination_example_django-admin.8ab6cabab559.png&quot; width=&quot;1920&quot; height=&quot;996&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination_example_django-admin.8ab6cabab559.png&amp;amp;w=480&amp;amp;sig=db87c27338ca00a7f36d62c98e5d660f67b5552d 480w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination_example_django-admin.8ab6cabab559.png&amp;amp;w=960&amp;amp;sig=e20848feb6273c7638b66c79cc022de30988ee58 960w, https://files.realpython.com/media/django-pagination_example_django-admin.8ab6cabab559.png 1920w&quot; sizes=&quot;75vw&quot; alt=&quot;Django Pagination Example: Django Admin&quot; data-asset=&quot;4207&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Instead of showing a list of all 3,776 items, the Django admin divides the content into 38 pages.
Again, imagine how overwhelming the Django admin interface would be if all the content were presented in one giant table!&lt;/p&gt;
&lt;p&gt;But pagination is not only used in the front-end design of websites.
It’s also very common to paginate the content of &lt;strong&gt;API responses&lt;/strong&gt;.
The &lt;a href=&quot;https://randomuser.me/&quot;&gt;Random User API&lt;/a&gt; is one of many &lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;REST APIs&lt;/a&gt; that give you the option of paginating the response:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/django-pagination-example-api.d53b6cf601d2.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/django-pagination-example-api.d53b6cf601d2.png&quot; width=&quot;1688&quot; height=&quot;886&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination-example-api.d53b6cf601d2.png&amp;amp;w=422&amp;amp;sig=194aa327ca7228d019613158c6fecd7096323a25 422w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/django-pagination-example-api.d53b6cf601d2.png&amp;amp;w=844&amp;amp;sig=0e74efbc95f95e9d0a9bc12fb786e80ebc70e994 844w, https://files.realpython.com/media/django-pagination-example-api.d53b6cf601d2.png 1688w&quot; sizes=&quot;75vw&quot; alt=&quot;Pagination Example: Random User API&quot; data-asset=&quot;4209&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;By adding a &lt;code&gt;results=2&lt;/code&gt; parameter, you tell the Random User API that you only want two results per response.
With the &lt;code&gt;page&lt;/code&gt; parameter, you can navigate to a specific page of these paginated responses.&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; Do you have any interesting examples of websites or APIs that use pagination? Share them with the community in the comments below! &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Once you know what pagination is, you’ll probably notice it often while surfing the Web.
In thinking about implementing pagination in your projects, it’s worth taking a closer look at when to use pagination and when not to use it.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/django-pagination/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/django-pagination/ »&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 #103: Becoming More Effective at Manipulating Data With Pandas</title>
      <id>https://realpython.com/podcasts/rpp/103/</id>
      <link href="https://realpython.com/podcasts/rpp/103/"/>
      <updated>2022-03-25T12:00:00+00:00</updated>
      <summary>Do you wonder if you&#x27;re taking the right approach when shaping data in pandas? Is your Jupyter workflow getting out of hand? This week on the show, Matt Harrison talks about his new book, &quot;Effective Pandas: Patterns for Data Manipulation.&quot;</summary>
      <content type="html">
        &lt;p&gt;Do you wonder if you&#x27;re taking the right approach when shaping data in pandas? Is your Jupyter workflow getting out of hand? This week on the show, Matt Harrison talks about his new book, &quot;Effective Pandas: Patterns for Data Manipulation.&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>Image Processing With the Python Pillow Library</title>
      <id>https://realpython.com/image-processing-with-the-python-pillow-library/</id>
      <link href="https://realpython.com/image-processing-with-the-python-pillow-library/"/>
      <updated>2022-03-23T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll learn how to use the Python Pillow library to deal with images and perform image processing. You&#x27;ll also explore using NumPy for further processing, including to create animations.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you look at an image, you see the objects and people in it. However, when you read an image programmatically with Python or any other language, the computer sees an array of numbers. In this tutorial, you’ll learn how to manipulate images and perform basic image processing using the Python Pillow library.&lt;/p&gt;
&lt;p&gt;Pillow and its predecessor, PIL, are the original Python libraries for dealing with images. Even though there are other Python libraries for image processing, Pillow remains an important tool for understanding and dealing with images.&lt;/p&gt;
&lt;p&gt;To manipulate and process images, Pillow provides tools that are similar to ones found in image processing software such as Photoshop. Some of the more modern Python image processing libraries are built on top of Pillow and often provide more advanced functionality.&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;Read images&lt;/strong&gt; with Pillow&lt;/li&gt;
&lt;li&gt;Perform &lt;strong&gt;basic image manipulation&lt;/strong&gt; operations&lt;/li&gt;
&lt;li&gt;Use Pillow for &lt;strong&gt;image processing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;NumPy&lt;/strong&gt; with Pillow for &lt;strong&gt;further processing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create animations&lt;/strong&gt; using Pillow&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This tutorial provides an overview of what you can achieve with the Python Pillow library through some of its most common methods. Once you gain confidence using these methods, then you can use Pillow’s &lt;a href=&quot;https://pillow.readthedocs.io/en/stable/reference/index.html&quot;&gt;documentation&lt;/a&gt; to explore the rest of the methods in the library. If you’ve never worked with images in Python before, this is a great opportunity to jump right in!&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll use several images, which you can download from the tutorial’s image repository:&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;Get Images:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/image-processing-with-the-python-pillow-library-images/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-image-processing-with-the-python-pillow-library-images&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to the images&lt;/a&gt; that you’ll manipulate and process with Pillow.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;With those images in hand, you’re now ready to get started with Pillow.&lt;/p&gt;
&lt;h2 id=&quot;basic-image-operations-with-the-python-pillow-library&quot;&gt;Basic Image Operations With the Python Pillow Library&lt;a class=&quot;headerlink&quot; href=&quot;#basic-image-operations-with-the-python-pillow-library&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://python-pillow.org&quot;&gt;Python Pillow library&lt;/a&gt; is a fork of an older library called PIL. PIL stands for Python Imaging Library, and it’s the original library that enabled Python to deal with images. PIL was discontinued in 2011 and only supports Python 2. To use its developers’ own description, Pillow is the friendly PIL fork that kept the library alive and includes support for Python 3.&lt;/p&gt;
&lt;p&gt;There’s more than one module in Python to deal with images and perform image processing. If you want to deal with images directly by manipulating their pixels, then you can use &lt;a href=&quot;https://numpy.org&quot;&gt;NumPy&lt;/a&gt; and &lt;a href=&quot;https://scipy.org&quot;&gt;SciPy&lt;/a&gt;. Other popular libraries for image processing are &lt;a href=&quot;https://docs.opencv.org/4.x/&quot;&gt;OpenCV&lt;/a&gt;, &lt;a href=&quot;https://scikit-image.org&quot;&gt;scikit-image&lt;/a&gt;, and &lt;a href=&quot;https://mahotas.readthedocs.io/en/latest/&quot;&gt;Mahotas&lt;/a&gt;. Some of these libraries are faster and more powerful than Pillow.&lt;/p&gt;
&lt;p&gt;However, Pillow remains an important tool for dealing with images. It provides image processing features that are similar to ones found in image processing software such as Photoshop. Pillow is often the preferred option for high-level image processing tasks that don’t require more advanced image processing expertise. It’s also often used for exploratory work when dealing with images.&lt;/p&gt;
&lt;p&gt;Pillow also has the advantage of being widely used by the Python community, and it doesn’t have the same steep learning curve as some of the other image processing libraries.&lt;/p&gt;
&lt;p&gt;You’ll need to install the library before you can use it. You can install Pillow 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;:&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;Pillow&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 Pillow
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now that you’ve installed the package, you’re ready to start familiarizing yourself with the &lt;a href=&quot;https://pillow.readthedocs.io/en/stable/reference/index.html&quot;&gt;Python Pillow library&lt;/a&gt; and perform basic manipulations of images.&lt;/p&gt;
&lt;h3 id=&quot;the-image-module-and-image-class-in-pillow&quot;&gt;The &lt;code&gt;Image&lt;/code&gt; Module and &lt;code&gt;Image&lt;/code&gt; Class in Pillow&lt;a class=&quot;headerlink&quot; href=&quot;#the-image-module-and-image-class-in-pillow&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The main class defined in Pillow is the &lt;a href=&quot;https://pillow.readthedocs.io/en/stable/reference/Image.html&quot;&gt;&lt;code&gt;Image&lt;/code&gt;&lt;/a&gt; class. When you read an image using Pillow, the image is stored in an object of type &lt;code&gt;Image&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;For the code in this section, you’ll need the image file named &lt;code&gt;buildings.jpg&lt;/code&gt; (&lt;a href=&quot;https://pixabay.com/users/memorycatcher-168384/&quot;&gt;image credit&lt;/a&gt;), which you can find in the image repository for this tutorial:&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;Get Images:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/image-processing-with-the-python-pillow-library-images/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-image-processing-with-the-python-pillow-library-images&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to the images&lt;/a&gt; that you’ll manipulate and process with Pillow.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;You can place this image file in the project folder that you’re working in.&lt;/p&gt;
&lt;p&gt;When exploring images with Pillow, it’s best to use an &lt;a href=&quot;https://realpython.com/interacting-with-python/&quot;&gt;interactive REPL environment&lt;/a&gt;. You’ll start by opening the image that you just downloaded:&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;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;PIL&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&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;filename&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;buildings.jpg&quot;&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;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&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;img&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&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;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;class &#x27;PIL.JpegImagePlugin.JpegImageFile&#x27;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isinstance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Image&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;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/image-processing-with-the-python-pillow-library/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/image-processing-with-the-python-pillow-library/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Basics: Code Your First Python Program</title>
      <id>https://realpython.com/courses/python-basics-first-program/</id>
      <link href="https://realpython.com/courses/python-basics-first-program/"/>
      <updated>2022-03-22T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll write your first Python program. Along the way, you&#x27;ll learn about errors, declare variables and inspect their values, and try your hand at writing comments.</summary>
      <content type="html">
        &lt;p&gt;In the previous Python Basics video course, you &lt;a href=&quot;https://realpython.com/courses/setting-up-python/&quot;&gt;set up Python&lt;/a&gt; on your computer. With Python installed, you&amp;rsquo;re ready ready to start coding!&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 your &lt;strong&gt;first Python program&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Learn what happens when you run a program with an &lt;strong&gt;error&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Learn how to &lt;strong&gt;declare a variable&lt;/strong&gt; and &lt;strong&gt;inspect its value&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Learn how to &lt;strong&gt;write comments&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This course can be enjoyed alone or as an accompaniment to &lt;a href=&quot;http://pythonbasicsbook.com&quot;&gt;Python Basics: A Practical Introduction to Python 3&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Ready to begin your Python journey? Let&amp;rsquo;s go!&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Timer Functions: Three Ways to Monitor Your Code</title>
      <id>https://realpython.com/python-timer/</id>
      <link href="https://realpython.com/python-timer/"/>
      <updated>2022-03-21T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll learn how to use Python timer functions to monitor how quickly your programs are running. You&#x27;ll use classes, context managers, and decorators to measure your program&#x27;s running time. You&#x27;ll learn the benefits of each method and which to use given the situation.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;While many developers &lt;a href=&quot;https://www.python.org/doc/essays/blurb/&quot;&gt;recognize&lt;/a&gt; Python as an effective programming language, pure Python programs may run more slowly than their counterparts in compiled languages like &lt;a href=&quot;https://realpython.com/c-for-python-programmers/&quot;&gt;C&lt;/a&gt;, Rust, and &lt;a href=&quot;https://realpython.com/oop-in-python-vs-java/&quot;&gt;Java&lt;/a&gt;. In this tutorial, you’ll learn how to use a &lt;strong&gt;Python timer&lt;/strong&gt; to monitor how quickly your programs are running.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to use:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;time.perf_counter()&lt;/code&gt;&lt;/strong&gt; to measure time in Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Classes&lt;/strong&gt; to keep state&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Context managers&lt;/strong&gt; to work with a block of code&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Decorators&lt;/strong&gt; to customize a function&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll also gain background knowledge into how classes, context managers, and decorators work. As you explore examples of each concept, you’ll be inspired to use one or several of them in your code, for timing code execution, as well as in other applications. Each method has its advantages, and you’ll learn which to use depending on the situation. Plus, you’ll have a working Python timer that you can use to monitor your programs!&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;Decorators Q&amp;amp;A Transcript:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/decorators-qa-2019/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-decorators-qa-2019&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to a 25-page chat log from our Python decorators Q&amp;amp;A session&lt;/a&gt; in the Real Python Community Slack where we discussed common decorator questions.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;python-timers&quot;&gt;Python Timers&lt;a class=&quot;headerlink&quot; href=&quot;#python-timers&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First, you’ll take a look at some example code that you’ll use throughout the tutorial. Later, you’ll add a &lt;strong&gt;Python timer&lt;/strong&gt; to this code to monitor its performance. You’ll also learn some of the simplest ways to measure the running time of this example.&lt;/p&gt;
&lt;h3 id=&quot;python-timer-functions&quot;&gt;Python Timer Functions&lt;a class=&quot;headerlink&quot; href=&quot;#python-timer-functions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you check out the built-in &lt;a href=&quot;https://docs.python.org/3/library/time.html&quot;&gt;&lt;code&gt;time&lt;/code&gt;&lt;/a&gt; module in Python, then you’ll notice several functions that can measure time:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/time.html#time.monotonic&quot;&gt;&lt;code&gt;monotonic()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/time.html#time.perf_counter&quot;&gt;&lt;code&gt;perf_counter()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/time.html#time.process_time&quot;&gt;&lt;code&gt;process_time()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/library/time.html#time.time&quot;&gt;&lt;code&gt;time()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;https://realpython.com/python37-new-features/&quot;&gt;Python 3.7&lt;/a&gt; introduced several new functions, like &lt;a href=&quot;https://docs.python.org/3/library/time.html#time.thread_time&quot;&gt;&lt;code&gt;thread_time()&lt;/code&gt;&lt;/a&gt;, as well as &lt;strong&gt;nanosecond&lt;/strong&gt; versions of all the functions above, named with an &lt;code&gt;_ns&lt;/code&gt; suffix. For example, &lt;a href=&quot;https://docs.python.org/3/library/time.html#time.perf_counter_ns&quot;&gt;&lt;code&gt;perf_counter_ns()&lt;/code&gt;&lt;/a&gt; is the nanosecond version of &lt;code&gt;perf_counter()&lt;/code&gt;. You’ll learn more about these functions later. For now, note what the documentation has to say about &lt;code&gt;perf_counter()&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Return the value (in fractional seconds) of a performance counter, i.e. a clock with the highest available resolution to measure a short duration. (&lt;a href=&quot;https://docs.python.org/3/library/time.html#time.perf_counter&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;First, you’ll use &lt;code&gt;perf_counter()&lt;/code&gt; to create a Python timer. &lt;a href=&quot;#other-python-timer-functions&quot;&gt;Later&lt;/a&gt;, you’ll compare this with other Python timer functions and learn why &lt;code&gt;perf_counter()&lt;/code&gt; is usually the best choice.&lt;/p&gt;
&lt;h3 id=&quot;example-download-tutorials&quot;&gt;Example: Download Tutorials&lt;a class=&quot;headerlink&quot; href=&quot;#example-download-tutorials&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To better compare the different ways that you can add a Python timer to your code, you’ll apply different Python timer functions to the same code example throughout this tutorial. If you already have code that you’d like to measure, then feel free to follow the examples with that instead.&lt;/p&gt;
&lt;p&gt;The example that you’ll use in this tutorial is a short function that uses the &lt;a href=&quot;https://pypi.org/project/realpython-reader/&quot;&gt;&lt;code&gt;realpython-reader&lt;/code&gt;&lt;/a&gt; package to download the latest tutorials available here on Real Python. To learn more about the Real Python Reader and how it works, check out &lt;a href=&quot;https://realpython.com/pypi-publish-python-package/&quot;&gt;How to Publish an Open-Source Python Package to PyPI&lt;/a&gt;. You can install &lt;code&gt;realpython-reader&lt;/code&gt; on your system with &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;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 pip install realpython-reader
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, you can &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;import&lt;/a&gt; the package as &lt;code&gt;reader&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You’ll store the example in a file named &lt;code&gt;latest_tutorial.py&lt;/code&gt;. The code consists of one function that downloads and prints the latest tutorial from Real Python:&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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# latest_tutorial.py&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;reader&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feed&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;    &lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Download and print the latest tutorial from Real Python&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;tutorial&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_article&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&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;tutorial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;10&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;linenos&quot;&gt;11&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;realpython-reader&lt;/code&gt; handles most of the hard work:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Line 3&lt;/strong&gt; imports &lt;code&gt;feed&lt;/code&gt; from &lt;code&gt;realpython-reader&lt;/code&gt;. This module contains functionality for downloading tutorials from the &lt;a href=&quot;https://realpython.com/contact/#rss-atom-feed&quot;&gt;Real Python feed&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Line 7&lt;/strong&gt; downloads the latest tutorial from Real Python. The number &lt;code&gt;0&lt;/code&gt; is an offset, where &lt;code&gt;0&lt;/code&gt; means the most recent tutorial, &lt;code&gt;1&lt;/code&gt; is the previous tutorial, and so on.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Line 8&lt;/strong&gt; prints the tutorial to the console.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Line 11&lt;/strong&gt; calls &lt;code&gt;main()&lt;/code&gt; when you run the script.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you run this example, your output will typically look something like this:&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 latest_tutorial.py
&lt;span class=&quot;gp&quot;&gt;# &lt;/span&gt;Python Timer Functions: Three Ways to Monitor Your Code

&lt;span class=&quot;go&quot;&gt;While many developers recognize Python as an effective programming language,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;pure Python programs may run more slowly than their counterparts in compiled&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;languages like C, Rust, and Java. In this tutorial, you&#x27;ll learn how to use&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;a Python timer to monitor how quickly your programs are running.&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;[ ... ]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Read the full article at https://realpython.com/python-timer/ »&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;The code may take a little while to run depending on your network, so you might want to use a Python timer to monitor the performance of the script.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-timer/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-timer/ »&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 #102: Making Your Notebook Interactive and Using Python&#x27;s Assert</title>
      <id>https://realpython.com/podcasts/rpp/102/</id>
      <link href="https://realpython.com/podcasts/rpp/102/"/>
      <updated>2022-03-18T12:00:00+00:00</updated>
      <summary>Would you like to build visualizations that allow your audience to play with data? How do you effectively use Python&#x27;s assert statement during development? This week on the show, Christopher Trudeau is here, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Would you like to build visualizations that allow your audience to play with data? How do you effectively use Python&#x27;s assert statement during development? This week on the show, Christopher Trudeau is here, and he&#x27;s brought 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>Build a Hash Table in Python With TDD</title>
      <id>https://realpython.com/python-hash-table/</id>
      <link href="https://realpython.com/python-hash-table/"/>
      <updated>2022-03-16T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll implement the classic hash table data structure using Python. Along the way, you&#x27;ll learn how to cope with various challenges such as hash code collisions while practicing test-driven development (TDD).</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Invented over half a century ago, the &lt;strong&gt;hash table&lt;/strong&gt; is a classic &lt;a href=&quot;https://en.wikipedia.org/wiki/Data_structure&quot;&gt;data structure&lt;/a&gt; that has been fundamental to programming. To this day, it helps solve many real-life problems, such as indexing database tables, caching computed values, or implementing sets. It often comes up in &lt;a href=&quot;https://realpython.com/learning-paths/python-interview/&quot;&gt;job interviews&lt;/a&gt;, and Python uses hash tables all over the place to make name lookups almost instantaneous.&lt;/p&gt;
&lt;p&gt;Even though Python comes with its own hash table called &lt;code&gt;dict&lt;/code&gt;, it can be helpful to understand how hash tables work behind the curtain. A coding assessment may even task you with building one. This tutorial will walk you through the steps of implementing a hash table from scratch as if there were none in Python. Along the way, you’ll face a few challenges that’ll introduce important concepts and give you an idea of why hash tables are so fast.&lt;/p&gt;
&lt;p&gt;In addition to this, you’ll get a hands-on crash course in &lt;strong&gt;test-driven development (TDD)&lt;/strong&gt; and will actively practice it while building your hash table in a step-by-step fashion. You’re not required to have any prior experience with TDD, but at the same time, you won’t get bored even if you do!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How a &lt;strong&gt;hash table&lt;/strong&gt; differs from a &lt;strong&gt;dictionary&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How you can &lt;strong&gt;implement a hash table&lt;/strong&gt; from scratch in Python&lt;/li&gt;
&lt;li&gt;How you can deal with &lt;strong&gt;hash collisions&lt;/strong&gt; and other challenges&lt;/li&gt;
&lt;li&gt;What the desired properties of a &lt;strong&gt;hash function&lt;/strong&gt; are&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;Python’s &lt;code&gt;hash()&lt;/code&gt;&lt;/strong&gt; works behind the scenes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’ll help if you’re already familiar with &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;Python dictionaries&lt;/a&gt; and have basic knowledge of &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; principles. To get the complete source code and the intermediate steps of the hash table implemented in this tutorial, follow the link below:&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;Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-hash-table-source-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-hash-table-source-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to download the source code&lt;/a&gt; that you’ll use to build a hash table in Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;get-to-know-the-hash-table-data-structure&quot;&gt;Get to Know the Hash Table Data Structure&lt;a class=&quot;headerlink&quot; href=&quot;#get-to-know-the-hash-table-data-structure&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before diving deeper, you should familiarize yourself with the terminology because it can get slightly confusing. Colloquially, the term &lt;strong&gt;hash table&lt;/strong&gt; or &lt;strong&gt;hash map&lt;/strong&gt; is often used interchangeably with the word &lt;strong&gt;dictionary&lt;/strong&gt;. However, there’s a subtle difference between the two concepts as the former is more specific than the latter.&lt;/p&gt;
&lt;h3 id=&quot;hash-table-vs-dictionary&quot;&gt;Hash Table vs Dictionary&lt;a class=&quot;headerlink&quot; href=&quot;#hash-table-vs-dictionary&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In computer science, a &lt;a href=&quot;https://en.wikipedia.org/wiki/Associative_array&quot;&gt;dictionary&lt;/a&gt; is an &lt;a href=&quot;https://en.wikipedia.org/wiki/Abstract_data_type&quot;&gt;abstract data type&lt;/a&gt; made up of &lt;strong&gt;keys&lt;/strong&gt; and &lt;strong&gt;values&lt;/strong&gt; arranged in pairs. Moreover, it defines the following operations for those elements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add a key-value pair&lt;/li&gt;
&lt;li&gt;Delete a key-value pair&lt;/li&gt;
&lt;li&gt;Update a key-value pair&lt;/li&gt;
&lt;li&gt;Find a value associated with the given key&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In a sense, this abstract data type resembles a &lt;strong&gt;bilingual dictionary&lt;/strong&gt;, where the keys are foreign words, and the values are their definitions or translations to other languages. But there doesn’t always have to be a sense of equivalence between keys and values. A &lt;strong&gt;phone book&lt;/strong&gt; is another example of a dictionary, which combines names with the corresponding phone numbers.&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; Anytime you &lt;em&gt;map&lt;/em&gt; one thing to another or &lt;em&gt;associate&lt;/em&gt; a value with a key, you’re essentially using a kind of a dictionary. That’s why dictionaries are also known as &lt;strong&gt;maps&lt;/strong&gt; or &lt;strong&gt;associative arrays&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Dictionaries have a few interesting properties. One of them is that you can think of a dictionary as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Function_(mathematics)&quot;&gt;mathematical function&lt;/a&gt; that projects one or more arguments to exactly one value. The direct consequences of that fact are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Only Key-Value Pairs:&lt;/strong&gt; You can’t have a key without the value or the other way around in a dictionary. They always go together.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arbitrary Keys and Values:&lt;/strong&gt; Keys and values can belong to two &lt;a href=&quot;https://en.wikipedia.org/wiki/Disjoint_sets&quot;&gt;disjoint sets&lt;/a&gt; of the same or separate types. Both keys and values may be almost anything, such as numbers, words, or even pictures.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unordered Key-Value Pairs:&lt;/strong&gt; Because of the last point, dictionaries don’t generally define any order for their key-value pairs. However, that might be implementation-specific.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unique Keys:&lt;/strong&gt; A dictionary can’t contain duplicate keys, because that would violate the definition of a function.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Non-Unique Values:&lt;/strong&gt; The same value can be associated with many keys, but it doesn’t have to.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are related concepts that extend the idea of a dictionary. For example, a &lt;a href=&quot;https://en.wikipedia.org/wiki/Multimap&quot;&gt;multimap&lt;/a&gt; lets you have more than one value per key, while a &lt;a href=&quot;https://en.wikipedia.org/wiki/Bidirectional_map&quot;&gt;bidirectional map&lt;/a&gt; not only maps keys to values but also provides mapping in the opposite direction. However, in this tutorial, you’re only going to consider the regular dictionary, which maps exactly one value to each key.&lt;/p&gt;
&lt;p&gt;Here’s a graphical depiction of a hypothetical dictionary, which maps some abstract concepts to their corresponding English words:&lt;/p&gt;
&lt;figure class=&quot;js-lightbox&quot;&gt;&lt;a href=&quot;https://files.realpython.com/media/dict_map.6ea6c6e33b4b.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block w-66&quot; src=&quot;https://files.realpython.com/media/dict_map.6ea6c6e33b4b.png&quot; width=&quot;1405&quot; height=&quot;1125&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/dict_map.6ea6c6e33b4b.png&amp;amp;w=351&amp;amp;sig=a6cd176c7fe425cd71f22c73f62280f32388b59e 351w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/dict_map.6ea6c6e33b4b.png&amp;amp;w=702&amp;amp;sig=30452c5332ce10b4c459181f482a38000dbc019e 702w, https://files.realpython.com/media/dict_map.6ea6c6e33b4b.png 1405w&quot; sizes=&quot;75vw&quot; alt=&quot;Graphical Depiction of a Dictionary Abstract Data Type&quot; data-asset=&quot;4019&quot;&gt;&lt;/a&gt;&lt;figcaption class=&quot;figure-caption text-center&quot;&gt;Graphical Depiction of a Dictionary Abstract Data Type&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;It’s a one-way map of keys to values, which are two completely different sets of elements. Right away, you can see fewer values than keys because the word &lt;em&gt;bow&lt;/em&gt; happens to be a &lt;a href=&quot;https://en.wikipedia.org/wiki/Homonym&quot;&gt;homonym&lt;/a&gt; with multiple meanings. Conceptually, this dictionary still contains four pairs, though. Depending on how you decided to implement it, you could reuse repeated values to conserve memory or duplicate them for simplicity.&lt;/p&gt;
&lt;p&gt;Now, how do you code such a dictionary in a programming language? The right answer is you &lt;em&gt;don’t&lt;/em&gt;, because most modern languages come with dictionaries as either &lt;a href=&quot;https://en.wikipedia.org/wiki/Primitive_data_type&quot;&gt;primitive data types&lt;/a&gt; or classes in their &lt;a href=&quot;https://en.wikipedia.org/wiki/Standard_library&quot;&gt;standard libraries&lt;/a&gt;. Python ships with a built-in &lt;code&gt;dict&lt;/code&gt; type, which already wraps a highly optimized data structure written in C so that you don’t have to write a dictionary yourself.&lt;/p&gt;
&lt;p&gt;Python’s &lt;code&gt;dict&lt;/code&gt; lets you perform all the dictionary operations listed at the beginning of this section:&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;glossary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;BDFL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Benevolent Dictator For Life&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;glossary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;GIL&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;s2&quot;&gt;&quot;Global Interpreter Lock&quot;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Add&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;glossary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;BDFL&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;s2&quot;&gt;&quot;Guido van Rossum&quot;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Update&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;del&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;glossary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;GIL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Delete&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;glossary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;BDFL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Search&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&#x27;Guido van Rossum&#x27;&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;glossary&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;{&#x27;BDFL&#x27;: &#x27;Guido van Rossum&#x27;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With the &lt;strong&gt;square bracket syntax&lt;/strong&gt; (&lt;code&gt;[ ]&lt;/code&gt;), you can add a new key-value pair to a dictionary. You can also update the value of or delete an existing pair identified by a key. Finally, you can look up the value associated with the given key.&lt;/p&gt;
&lt;p&gt;That said, you may ask a different question. How does the built-in dictionary actually work? How does it map keys of arbitrary data types, and how does it do it so quickly?&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-hash-table/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-hash-table/ »&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>Sorting Data in Python With Pandas</title>
      <id>https://realpython.com/courses/sorting-data-python-pandas/</id>
      <link href="https://realpython.com/courses/sorting-data-python-pandas/"/>
      <updated>2022-03-15T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to sort data in a pandas DataFrame using the pandas sort functions sort_values() and sort_index(). You&#x27;ll learn how to sort by one or more columns and by index in ascending or descending order.</summary>
      <content type="html">
        &lt;p&gt;Learning pandas &lt;strong&gt;sort methods&lt;/strong&gt; is a great way to start with or practice doing basic &lt;a href=&quot;https://realpython.com/pandas-python-explore-dataset/&quot;&gt;data analysis using Python&lt;/a&gt;. Most commonly, data analysis is done with &lt;a href=&quot;https://realpython.com/openpyxl-excel-spreadsheets-python/&quot;&gt;spreadsheets&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-sql-libraries/&quot;&gt;SQL&lt;/a&gt;, or &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt;. One of the great things about using pandas is that it can handle a large amount of data and offers highly performant data manipulation capabilities.&lt;/p&gt;
&lt;p&gt;In this video course, you&amp;rsquo;ll learn how to use &lt;code&gt;.sort_values()&lt;/code&gt; and &lt;code&gt;.sort_index()&lt;/code&gt;, which will enable you to sort data efficiently in a DataFrame.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this video course, you&amp;rsquo;ll know how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sort a &lt;strong&gt;pandas DataFrame&lt;/strong&gt; by the values of one or more columns&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;ascending&lt;/code&gt; parameter to change the &lt;strong&gt;sort order&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Sort a DataFrame by its &lt;code&gt;index&lt;/code&gt; using &lt;strong&gt;&lt;code&gt;.sort_index()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Organize &lt;strong&gt;missing data&lt;/strong&gt; while sorting values&lt;/li&gt;
&lt;li&gt;Sort a DataFrame &lt;strong&gt;in-place&lt;/strong&gt; using &lt;code&gt;inplace&lt;/code&gt; set to &lt;code&gt;True&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Class Constructors: Control Your Object Instantiation</title>
      <id>https://realpython.com/python-class-constructor/</id>
      <link href="https://realpython.com/python-class-constructor/"/>
      <updated>2022-03-14T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how class constructors work in Python. You&#x27;ll also explore Python&#x27;s instantiation process, which has two main steps: instance creation and instance initialization.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Class constructors are a fundamental part of &lt;strong&gt;object-oriented programming&lt;/strong&gt; in Python. They allow you to create and properly initialize objects of a given class, making those objects ready to use. Class constructors internally trigger Python’s instantiation process, which runs through two main steps: &lt;strong&gt;instance creation&lt;/strong&gt; and &lt;strong&gt;instance initialization&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you want to dive deeper into how Python internally constructs objects and learn how to customize the process, then this tutorial is for you.&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 Python’s internal &lt;strong&gt;instantiation process&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Customize object initialization using &lt;strong&gt;&lt;code&gt;.__init__()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Fine-tune object creation by overriding &lt;strong&gt;&lt;code&gt;.__new__()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this knowledge, you’ll be able to tweak the creation and initialization of objects in your custom Python classes, which will give you control over the instantiation process at a more advanced level.&lt;/p&gt;
&lt;p&gt;To better understand the examples and concepts in this tutorial, you should be familiar with &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt; and &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-special-method&quot;&gt;special methods&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 Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-oop/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-oop&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to a free Python OOP Cheat Sheet&lt;/a&gt; that points you to the best tutorials, videos, and books to learn more about Object-Oriented Programming with Python.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;pythons-class-constructors-and-the-instantiation-process&quot;&gt;Python’s Class Constructors and the Instantiation Process&lt;a class=&quot;headerlink&quot; href=&quot;#pythons-class-constructors-and-the-instantiation-process&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Like many other programming languages, Python supports &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented programming&lt;/a&gt;. At the heart of Python’s object-oriented capabilities, you’ll find the &lt;a href=&quot;https://realpython.com/python-keywords/#structure-keywords-def-class-with-as-pass-lambda&quot;&gt;&lt;code&gt;class&lt;/code&gt;&lt;/a&gt; keyword, which allows you to define custom classes that can have &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/#class-and-instance-attributes&quot;&gt;attributes&lt;/a&gt; for storing data and &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/#instance-methods&quot;&gt;methods&lt;/a&gt; for providing behaviors.&lt;/p&gt;
&lt;p&gt;Once you have a class to work with, then you can start creating new &lt;strong&gt;instances&lt;/strong&gt; or &lt;strong&gt;objects&lt;/strong&gt; of that class, which is an efficient way to reuse functionality in your code.&lt;/p&gt;
&lt;p&gt;Creating and initializing objects of a given class is a fundamental step in object-oriented programming. This step is often referred to as &lt;strong&gt;object construction&lt;/strong&gt; or &lt;strong&gt;instantiation&lt;/strong&gt;. The tool responsible for running this instantiation process is commonly known as a &lt;strong&gt;class constructor&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;getting-to-know-pythons-class-constructors&quot;&gt;Getting to Know Python’s Class Constructors&lt;a class=&quot;headerlink&quot; href=&quot;#getting-to-know-pythons-class-constructors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In Python, to construct an object of a given class, you just need to call the class with appropriate arguments, as you would call any &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;function&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;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;pass&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Call the class to construct an object&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;SomeClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;__main__.SomeClass object at 0x7fecf442a140&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you define &lt;code&gt;SomeClass&lt;/code&gt; using the &lt;code&gt;class&lt;/code&gt; keyword. This class is currently empty because it doesn’t have attributes or methods. Instead, the class’s body only contains a &lt;a href=&quot;https://realpython.com/python-pass/&quot;&gt;&lt;code&gt;pass&lt;/code&gt;&lt;/a&gt; statement as a placeholder statement that does nothing.&lt;/p&gt;
&lt;p&gt;Then you create a new instance of &lt;code&gt;SomeClass&lt;/code&gt; by calling the class with a pair of parentheses. In this example, you don’t need to pass any argument in the call because your class doesn’t take arguments yet.&lt;/p&gt;
&lt;p&gt;In Python, when you call a class as you did in the above example, you’re calling the class constructor, which creates, initializes, and returns a new object by triggering Python’s internal instantiation process.&lt;/p&gt;
&lt;p&gt;A final point to note is that calling a class isn’t the same as calling an &lt;em&gt;instance&lt;/em&gt; of a class. These are two different and unrelated topics. To make a class’s instance callable, you need to implement a &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__call__&quot;&gt;&lt;code&gt;.__call__()&lt;/code&gt;&lt;/a&gt; special method, which has nothing to do with Python’s instantiation process.&lt;/p&gt;
&lt;h3 id=&quot;understanding-pythons-instantiation-process&quot;&gt;Understanding Python’s Instantiation Process&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-pythons-instantiation-process&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You trigger Python’s &lt;strong&gt;instantiation process&lt;/strong&gt; whenever you call a Python class to create a new instance. This process runs through two separate steps, which you can describe as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Create a new instance&lt;/strong&gt; of the target class&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Initialize the new instance&lt;/strong&gt; with an appropriate initial &lt;a href=&quot;https://en.wikipedia.org/wiki/State_(computer_science)&quot;&gt;state&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To run the first step, Python classes have a special method called &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__new__&quot;&gt;&lt;code&gt;.__new__()&lt;/code&gt;&lt;/a&gt;, which is responsible for creating and returning a new empty object. Then another special method, &lt;a href=&quot;https://docs.python.org/3/reference/datamodel.html#object.__init__&quot;&gt;&lt;code&gt;.__init__()&lt;/code&gt;&lt;/a&gt;, takes the resulting object, along with the class constructor’s arguments.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.__init__()&lt;/code&gt; method takes the new object as its first argument, &lt;code&gt;self&lt;/code&gt;. Then it sets any required instance attribute to a valid state using the arguments that the class constructor passed to it.&lt;/p&gt;
&lt;p&gt;In short, Python’s instantiation process starts with a call to the class constructor, which triggers the &lt;strong&gt;instance creator&lt;/strong&gt;, &lt;code&gt;.__new__()&lt;/code&gt;, to create a new empty object. The process continues with the &lt;strong&gt;instance initializer&lt;/strong&gt;, &lt;code&gt;.__init__()&lt;/code&gt;, which takes the constructor’s arguments to initialize the newly created object.&lt;/p&gt;
&lt;p&gt;To explore how Python’s instantiation process works internally, consider the following example of a &lt;code&gt;Point&lt;/code&gt; class that implements a custom version of both methods, &lt;code&gt;.__new__()&lt;/code&gt; and &lt;code&gt;.__init__()&lt;/code&gt;, for demonstration purposes:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-class-constructor/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-class-constructor/ »&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 #101: Tools for Setting Up Python on a New Machine</title>
      <id>https://realpython.com/podcasts/rpp/101/</id>
      <link href="https://realpython.com/podcasts/rpp/101/"/>
      <updated>2022-03-11T12:00:00+00:00</updated>
      <summary>There are many ways to get Python installed on your computer. If you were going to start fresh, what tools would you use? What if you need to manage multiple versions of Python and virtual environments? What about all the additional tools that make your coding workflow complete? This week on the show, Calvin Hendryx-Parker is here to talk about bootstrapping your Python environment.</summary>
      <content type="html">
        &lt;p&gt;There are many ways to get Python installed on your computer. If you were going to start fresh, what tools would you use? What if you need to manage multiple versions of Python and virtual environments? What about all the additional tools that make your coding workflow complete? This week on the show, Calvin Hendryx-Parker is here to talk about bootstrapping your Python environment.&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 3.11 Preview: Even Better Error Messages</title>
      <id>https://realpython.com/python311-error-messages/</id>
      <link href="https://realpython.com/python311-error-messages/"/>
      <updated>2022-03-09T14:00:00+00:00</updated>
      <summary>Python 3.11 will be released in October 2022. In this tutorial, you&#x27;ll install the latest alpha release of Python 3.11 in order to preview one of its anticipated features: more precise error messages that&#x27;ll help you debug your code more efficiently.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python 3.11 will be released in October 2022. Even though October is still months away, you can already preview some of the upcoming features, including how Python 3.11 will offer more readable and actionable error messages.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Install&lt;/strong&gt; Python 3.11 Alpha on your computer, next to your current Python installations&lt;/li&gt;
&lt;li&gt;Interpret the &lt;strong&gt;improved error messages&lt;/strong&gt; in Python 3.11 and learn to &lt;strong&gt;more efficiently debug&lt;/strong&gt; your code&lt;/li&gt;
&lt;li&gt;Connect these improvements to the &lt;strong&gt;PEG parser&lt;/strong&gt; and the &lt;strong&gt;better error messages&lt;/strong&gt; in Python 3.10&lt;/li&gt;
&lt;li&gt;Explore &lt;strong&gt;third-party packages&lt;/strong&gt; offering enhanced error messages&lt;/li&gt;
&lt;li&gt;Test smaller improvements in Python 3.11, including &lt;strong&gt;new math functions&lt;/strong&gt; and more &lt;strong&gt;readable fractions&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are many other improvements and features coming in Python 3.11. Keep track of &lt;a href=&quot;https://docs.python.org/3.11/whatsnew/3.11.html&quot;&gt;what’s new&lt;/a&gt; in the changelog for an up-to-date list.&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 Bonus:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-mastery-course/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-mastery-course&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;5 Thoughts On Python Mastery&lt;/a&gt;, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;python-311-alpha&quot;&gt;Python 3.11 Alpha&lt;a class=&quot;headerlink&quot; href=&quot;#python-311-alpha&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A new version of Python is released in October each year. The code is developed and tested over a &lt;a href=&quot;https://www.python.org/dev/peps/pep-0602/&quot;&gt;seventeen-month period&lt;/a&gt; before the release date. New features are implemented during the &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha&quot;&gt;alpha phase&lt;/a&gt;, which lasts until May, about five months before the final release.&lt;/p&gt;
&lt;p&gt;About &lt;a href=&quot;https://www.python.org/dev/peps/pep-0664/&quot;&gt;once a month&lt;/a&gt; during the alpha phase, Python’s core developers release a new &lt;strong&gt;alpha version&lt;/strong&gt; to show off the new features, test them, and get early feedback. Currently, the latest version of Python 3.11 is &lt;strong&gt;3.11.0 alpha 5&lt;/strong&gt;, released on February 3, 2022.&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; This tutorial uses the fifth alpha version of Python 3.11. You might experience small differences if you use a later version. However, you can expect most of what you learn here to stay the same through the alpha and beta phases and in the final release of Python 3.11.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The first &lt;strong&gt;beta release&lt;/strong&gt; of Python 3.11 is planned for May 6, 2022. Typically, no new features are added during the &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta&quot;&gt;beta phase&lt;/a&gt;. Instead, the time between the feature freeze and the release date is used to test and solidify the code.&lt;/p&gt;
&lt;h3 id=&quot;cool-new-features&quot;&gt;Cool New Features&lt;a class=&quot;headerlink&quot; href=&quot;#cool-new-features&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Some of the currently announced highlights of Python 3.11 include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Enhanced error messages&lt;/strong&gt;, which will help you more effectively debug your code&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exception groups&lt;/strong&gt;, which will allow programs to raise and handle multiple exceptions at the same time&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimizations&lt;/strong&gt;, promising to make Python 3.11 significantly faster than previous versions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Static typing&lt;/strong&gt; improvements, which will let you &lt;a href=&quot;https://realpython.com/python-type-checking/#annotations&quot;&gt;annotate&lt;/a&gt; your code more precisely&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There’s a lot to look forward to in the upcoming Python 3.11 release! In this tutorial, you’ll focus on how the enhanced error reporting can improve your developer experience by letting you debug your code more efficiently. You’ll also get a peek at some of the other, smaller features that’ll be shipping with Python 3.11.&lt;/p&gt;
&lt;h3 id=&quot;installation&quot;&gt;Installation&lt;a class=&quot;headerlink&quot; href=&quot;#installation&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To play with the code examples in this tutorial, you’ll need to install a version of Python 3.11 onto your system. In this section, you’ll learn about a few different ways to do this: using &lt;strong&gt;Docker&lt;/strong&gt;, using &lt;strong&gt;pyenv&lt;/strong&gt;, or installing from &lt;strong&gt;source&lt;/strong&gt;. Pick the one that works best for you and your system.&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; Alpha versions are previews of upcoming features. While most features will work well, you shouldn’t depend on any Python 3.11 alpha version in production or anywhere else where bugs will have serious consequences.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you have access to &lt;a href=&quot;https://docs.docker.com/get-docker/&quot;&gt;Docker&lt;/a&gt; on your system, then you can download the latest version of Python 3.11 by pulling and running the &lt;code&gt;python:3.11-rc-slim&lt;/code&gt; &lt;a href=&quot;https://hub.docker.com/_/python&quot;&gt;Docker image&lt;/a&gt;:&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;docker pull python:3.11-rc-slim
&lt;span class=&quot;go&quot;&gt;Unable to find image &#x27;python:3.11-rc-slim&#x27; locally&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;latest: Pulling from library/python&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[...]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;docker run -it --rm python:3.11-rc-slim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This drops you into a Python 3.11 REPL. Check out &lt;a href=&quot;https://realpython.com/python-versions-docker/#running-python-in-a-docker-container&quot;&gt;Run Python Versions in Docker&lt;/a&gt; for more information about how you can work with Python through Docker, including how you can run scripts.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;pyenv&lt;/a&gt; tool is great for managing different versions of Python on your system, and you can use it to install Python 3.11 Alpha if you like. It comes with two different versions, one for Windows and one for Linux and macOS:&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;p&gt;On Windows, you can use &lt;a href=&quot;https://pyenv-win.github.io/pyenv-win/&quot;&gt;pyenv-win&lt;/a&gt;. First update your &lt;code&gt;pyenv&lt;/code&gt; installation:&lt;/p&gt;
&lt;div class=&quot;highlight doscon&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;C:\&amp;gt;&lt;/span&gt; pyenv update
&lt;span class=&quot;go&quot;&gt;:: [Info] ::  Mirror: https://www.python.org/ftp/python&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;Doing an update ensures that you can install the latest version of Python. You could also &lt;a href=&quot;https://pyenv-win.github.io/pyenv-win/#how-to-update-pyenv&quot;&gt;update &lt;code&gt;pyenv&lt;/code&gt; manually&lt;/a&gt;.&lt;/p&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;p&gt;On Linux and macOS, you can use &lt;a href=&quot;https://github.com/pyenv/pyenv&quot;&gt;pyenv&lt;/a&gt;. First update your &lt;code&gt;pyenv&lt;/code&gt; installation, using the &lt;a href=&quot;https://github.com/pyenv/pyenv-update&quot;&gt;&lt;code&gt;pyenv-update&lt;/code&gt;&lt;/a&gt; plugin:&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;pyenv update
&lt;span class=&quot;go&quot;&gt;Updating /home/realpython/.pyenv...&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;Doing an update ensures that you can install the latest version of Python. If you don’t want to use the update plugin, you can &lt;a href=&quot;https://github.com/pyenv/pyenv#upgrading&quot;&gt;update &lt;code&gt;pyenv&lt;/code&gt; manually&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Use &lt;code&gt;pyenv install --list&lt;/code&gt; to check which versions of Python 3.11 are available. Then, install the latest one:&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;pyenv install &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;.11.0a5
&lt;span class=&quot;go&quot;&gt;Downloading Python-3.11.0a5.tar.xz...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[...]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python311-error-messages/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python311-error-messages/ »&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>Counting With Python&#x27;s Counter</title>
      <id>https://realpython.com/courses/counting-python-counter/</id>
      <link href="https://realpython.com/courses/counting-python-counter/"/>
      <updated>2022-03-08T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn how to use Python&#x27;s Counter to count several repeated objects at once.</summary>
      <content type="html">
        &lt;p&gt;Counting several repeated objects at once is a common problem in programming. Python offers a bunch of tools and techniques you can use to approach this problem. However, Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;Counter&lt;/code&gt;&lt;/strong&gt; from &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; provides a clean, efficient, and Pythonic solution.&lt;/p&gt;
&lt;p&gt;This &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt; subclass provides efficient counting capabilities out of the box. Understanding &lt;code&gt;Counter&lt;/code&gt; and how to use it efficiently is a convenient skill to have as a Python developer.&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;Count &lt;strong&gt;several repeated objects&lt;/strong&gt; at once&lt;/li&gt;
&lt;li&gt;Create counters with Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;Counter&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Retrieve the &lt;strong&gt;most common objects&lt;/strong&gt; in a counter&lt;/li&gt;
&lt;li&gt;Update &lt;strong&gt;object counts&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;Counter&lt;/code&gt; to facilitate &lt;strong&gt;further computations&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implement &lt;code&gt;Counter&lt;/code&gt; instances as &lt;strong&gt;multisets&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python News: What&#x27;s New From February 2022?</title>
      <id>https://realpython.com/python-news-february-2022/</id>
      <link href="https://realpython.com/python-news-february-2022/"/>
      <updated>2022-03-07T14:00:00+00:00</updated>
      <summary>In February 2022, Python 3.11 Alpha 5 was released, and the schedule for the upcoming PyCon US became available. In this article, you&#x27;ll get the details of these exciting events and catch up on other important developments in the world of Python.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;In &lt;strong&gt;February 2022&lt;/strong&gt;, another preview release of &lt;strong&gt;Python 3.11&lt;/strong&gt; became available for early adopters to test and share their feedback. Shortly afterward, the Python steering council announced that Python 3.11 would also include a &lt;strong&gt;TOML parser&lt;/strong&gt; in the standard library. In addition, &lt;strong&gt;GitHub Issues&lt;/strong&gt; will soon become the official bug tracking system for Python.&lt;/p&gt;
&lt;p&gt;In other news, &lt;strong&gt;PyCon US 2022&lt;/strong&gt; shared its conference schedule. The Python Software Foundation (PSF) wants to &lt;strong&gt;hire two contract developers&lt;/strong&gt; to improve the Python Package Index (PyPI). Apple is finally &lt;strong&gt;removing Python 2.7&lt;/strong&gt; from macOS.&lt;/p&gt;
&lt;p&gt;Let’s dive into the biggest &lt;strong&gt;Python news&lt;/strong&gt; from the past month!&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&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;python-311-alpha-5-released&quot;&gt;Python 3.11 Alpha 5 Released&lt;a class=&quot;headerlink&quot; href=&quot;#python-311-alpha-5-released&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While the final release of &lt;strong&gt;Python 3.11&lt;/strong&gt; is planned for &lt;strong&gt;October 2022&lt;/strong&gt;, which is still months ahead, you can already check out what’s coming. According to the development and release schedule described in &lt;a href=&quot;https://www.python.org/dev/peps/pep-0664/&quot;&gt;PEP 664&lt;/a&gt;, Python 3.11 is now in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha&quot;&gt;alpha phase&lt;/a&gt; of its release cycle, which is meant to collect early feedback from users like you. At the beginning of February, &lt;a href=&quot;https://www.python.org/downloads/release/python-3110a5/&quot;&gt;3.11.0a5&lt;/a&gt;, the fifth of seven planned alpha releases, became available for testing.&lt;/p&gt;
&lt;p&gt;To play around with an alpha release of Python, you can grab the corresponding &lt;a href=&quot;https://realpython.com/python-versions-docker/&quot;&gt;Docker image&lt;/a&gt; from Docker Hub, install an alternative Python interpreter with &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;pyenv&lt;/a&gt;, or build the &lt;a href=&quot;https://realpython.com/cpython-source-code-guide/&quot;&gt;CPython source code&lt;/a&gt; using a compiler tool. The source code method lets you clone &lt;a href=&quot;https://github.com/python/cpython&quot;&gt;CPython’s repository&lt;/a&gt; from GitHub and check out a bleeding-edge snapshot without waiting for an alpha release.&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; Features under development might be unstable and buggy, and they can be modified or removed from the final release without notice. As a result of that, you should never use preview releases in a production environment!&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;If you’d like to explore some of the most exciting features coming to Python 3.11, then make sure you can run the alpha release of the interpreter. You’ll find the commands to download and run &lt;strong&gt;Python 3.11.0a5&lt;/strong&gt; below:&lt;/p&gt;
&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_card6949bc&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;#collapse6949bc&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapse6949bc&quot; markdown=&quot;1&quot;&gt;&lt;span class=&quot;float-left&quot; markdown=&quot;1&quot;&gt;Run with Docker&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_card6949bc&quot; id=&quot;collapse6949bc&quot;&gt;
&lt;div class=&quot;card-body&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;docker pull python:3.11.0a5-slim
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;docker run -it --rm python:3.11.0a5-slim
&lt;span class=&quot;go&quot;&gt;Python 3.11.0a5 (main, Feb 25 2022, 20:02:52) [GCC 10.2.1 20210110] on linux&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_cardd76d73&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;#collapsed76d73&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapsed76d73&quot; markdown=&quot;1&quot;&gt;&lt;span class=&quot;float-left&quot; markdown=&quot;1&quot;&gt;Run with pyenv&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_cardd76d73&quot; id=&quot;collapsed76d73&quot;&gt;
&lt;div class=&quot;card-body&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;pyenv update
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pyenv install &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;.11.0a5
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pyenv &lt;span class=&quot;nb&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;.11.0a5
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python
&lt;span class=&quot;go&quot;&gt;Python 3.11.0a5 (main, Mar  1 2022, 10:05:02) [GCC 9.3.0] on linux&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;card mb-3&quot; id=&quot;collapse_card667805&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;#collapse667805&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;collapse667805&quot; markdown=&quot;1&quot;&gt;&lt;span class=&quot;float-left&quot; markdown=&quot;1&quot;&gt;Run from Source Code&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_card667805&quot; id=&quot;collapse667805&quot;&gt;
&lt;div class=&quot;card-body&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;git clone git@github.com:python/cpython.git
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; cpython/
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;git checkout v3.11.0a5
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;./configure
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;make
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;./python
&lt;span class=&quot;go&quot;&gt;Python 3.11.0a5 (tags/v3.11.0a5:c4e4b91557, Mar  1 2022, 17:48:56) [GCC 9.3.0] on linux&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;So what’s all the hype about this alpha release? There are several big and small improvements, but for now, let’s focus on some of the Python 3.11 highlights!&lt;/p&gt;
&lt;h3 id=&quot;pep-657-error-locations-in-tracebacks&quot;&gt;PEP 657: Error Locations in Tracebacks&lt;a class=&quot;headerlink&quot; href=&quot;#pep-657-error-locations-in-tracebacks&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Python 3.10 has already greatly &lt;a href=&quot;https://realpython.com/python310-new-features/#better-error-messages&quot;&gt;improved its error messages&lt;/a&gt;. By pinpointing the root cause, providing context, and even suggesting fixes, error messages have become more human-friendly and helpful for Python beginners. Python 3.11 takes error messaging one step further to improve the debugging experience and expose an API for code analysis tools.&lt;/p&gt;
&lt;p&gt;Sometimes, a single line of code can contain multiple instructions or a complex expression, which would be hard to debug in older Python versions:&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;cat test.py
&lt;span class=&quot;go&quot;&gt;x, y, z = 1, 2, 0&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;w = x / y / z&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python3.10 test.py
&lt;span class=&quot;go&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  File &quot;/home/realpython/test.py&quot;, line 2, in &amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    w = x / y / z&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;ZeroDivisionError: float division by zero&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python3.11a5 test.py
&lt;span class=&quot;go&quot;&gt;  File &quot;/home/realpython/test.py&quot;, line 2, in &amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;    w = x / y / z&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        ~~~~~~^~~&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;ZeroDivisionError: float division by zero&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, one of the variables causes a zero division error. Python 3.10 tells you about the problem, but it doesn’t indicate the culprit. In Python 3.11, the &lt;a href=&quot;https://realpython.com/python-traceback/&quot;&gt;traceback&lt;/a&gt; will include &lt;strong&gt;visual feedback&lt;/strong&gt; about the exact location on a line that raised an exception. You’ll also have a &lt;strong&gt;programmatic way&lt;/strong&gt; of getting that same information for tools.&lt;/p&gt;
&lt;p&gt;Note that some of these enhanced tracebacks won’t work for code evaluated on the fly in the Python &lt;a href=&quot;https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop&quot;&gt;REPL&lt;/a&gt;, because the tracebacks require pre-compiled bytecode to keep track of the source lines:&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;go&quot;&gt;Python 3.11.0a5 (main, Mar  1 2022, 10:05:02) [GCC 9.3.0] on linux&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&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;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z&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;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;0&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;w&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;
&lt;span class=&quot;gt&quot;&gt;Traceback (most recent call last):&lt;/span&gt;
  File &lt;span class=&quot;nb&quot;&gt;&quot;&amp;lt;stdin&amp;gt;&quot;&lt;/span&gt;, line &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;, in &lt;span class=&quot;n&quot;&gt;&amp;lt;module&amp;gt;&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;ZeroDivisionError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;float division by zero&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For more information on error locations in tracebacks, see &lt;a href=&quot;https://www.python.org/dev/peps/pep-0657/&quot;&gt;PEP 657&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;pep-654-exception-groups-and-except&quot;&gt;PEP 654: Exception Groups and &lt;code&gt;except*&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#pep-654-exception-groups-and-except&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-news-february-2022/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-news-february-2022/ »&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 #100: Defining Optional Arguments and Moving Beyond &quot;Beginner&quot; Python</title>
      <id>https://realpython.com/podcasts/rpp/100/</id>
      <link href="https://realpython.com/podcasts/rpp/100/"/>
      <updated>2022-03-04T12:00:00+00:00</updated>
      <summary>How do you define Python functions that accept optional arguments or default values? Are you wondering how to go beyond being a beginner with Python? This week on the show, Christopher Trudeau is here, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;How do you define Python functions that accept optional arguments or default values? Are you wondering how to go beyond being a beginner with Python? This week on the show, Christopher Trudeau is here, and he&#x27;s brought 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>Manage Your To-Do Lists Using Python and Django</title>
      <id>https://realpython.com/django-todo-lists/</id>
      <link href="https://realpython.com/django-todo-lists/"/>
      <updated>2022-03-02T14:00:00+00:00</updated>
      <summary>Use Django to build a to-do list manager app. This step-by-step project will teach you how to use Django&#x27;s class-based views to build a powerful app while dramatically reducing your development time.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Have you ever struggled to keep track of the things that you need to do? Perhaps you’re in the habit of using a handwritten to-do list to remind you of what needs doing, and by when. But handwritten notes have a way of getting lost or forgotten.
Because you’re a Python coder, it makes sense to build a Django to-do list manager!&lt;/p&gt;
&lt;p&gt;In this step-by-step tutorial, you’re going to create a web app using Django. You’ll learn how Django can integrate with a database that stores all your to-do items in lists that you can define. Each item will have a title, a description, and a deadline. With this app, you can manage your own deadlines and help your entire team stay on track!&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 a &lt;strong&gt;web app&lt;/strong&gt; using Django&lt;/li&gt;
&lt;li&gt;Build a &lt;strong&gt;data model&lt;/strong&gt; with &lt;strong&gt;one-to-many relationships&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use the &lt;strong&gt;Django admin&lt;/strong&gt; interface to explore your data model and add test data&lt;/li&gt;
&lt;li&gt;Design &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/topics/templates/&quot;&gt;templates&lt;/a&gt; for displaying your lists&lt;/li&gt;
&lt;li&gt;Leverage &lt;strong&gt;class-based views&lt;/strong&gt; to handle the standard database operations&lt;/li&gt;
&lt;li&gt;Control the Django &lt;strong&gt;URL dispatcher&lt;/strong&gt; by creating &lt;strong&gt;URL configurations&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Along the way, you’ll learn how Django’s &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/topics/class-based-views/&quot;&gt;class-based views&lt;/a&gt; leverage the power of &lt;a href=&quot;https://en.wikipedia.org/wiki/Object-oriented_programming&quot;&gt;object-oriented programming&lt;/a&gt;. That’ll save you a ton of development effort!&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;Get Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/django-todo-lists-project-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-django-todo-lists-project-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get the source code you’ll use&lt;/a&gt; to build your to-do list app.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;demo&quot;&gt;Demo&lt;a class=&quot;headerlink&quot; href=&quot;#demo&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this tutorial, you’ll build a Django to-do list manager. Your main page will display all of your to-do lists. By clicking the &lt;em&gt;Add a new list&lt;/em&gt; button, you’ll display a page where you can name and create a new list:&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/662503907?background=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div&gt;

&lt;/figure&gt;

&lt;p&gt;You’ll be able to add to-do items to your list by clicking &lt;em&gt;Add a new item&lt;/em&gt;. There, you can give your item a title, and you can add more details in the &lt;em&gt;Description&lt;/em&gt; box. You can even set a due date.&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;To build this app, you’ll start by creating a virtual environment and setting up a Django project.
Next, you’ll design a &lt;a href=&quot;https://en.wikipedia.org/wiki/Data_model&quot;&gt;data model&lt;/a&gt; that represents the relationships between to-do items and lists.
You’ll use Django’s built-in &lt;a href=&quot;https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping&quot;&gt;object-relational mapping&lt;/a&gt; tool to automatically generate the database and tables that’ll support this model.&lt;/p&gt;
&lt;p&gt;As you develop your Django to-do list app, you’ll use Django’s handy &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/ref/django-admin/#runserver&quot;&gt;&lt;code&gt;runserver&lt;/code&gt;&lt;/a&gt; command whenever you need to verify that things are working as expected. This can help even before your web pages are ready, thanks to Django’s ready-made &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/ref/contrib/admin/&quot;&gt;admin&lt;/a&gt; interface.&lt;/p&gt;
&lt;p&gt;Next, you’ll develop your own web pages to display your app. In Django, these take the form of &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/topics/templates/&quot;&gt;templates&lt;/a&gt;. Templates are skeleton HTML pages that can be populated with real application data.&lt;/p&gt;
&lt;p&gt;Templates aren’t meant to provide much logic, such as deciding which template to display and what data to send it. To perform that logic, you’ll need &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/topics/http/views/&quot;&gt;views&lt;/a&gt;. Django’s views are the natural home for the application’s logic.&lt;/p&gt;
&lt;p&gt;You’ll code views and templates for list creation and updates, as well as for the items that those lists will contain.
You’ll learn how to use Django’s &lt;a href=&quot;https://docs.djangoproject.com/en/4.0/topics/http/urls/&quot;&gt;URL dispatcher&lt;/a&gt; to connect your pages and pass them the data that they need.
Next, you’ll add more views and templates that enable your users to delete lists and items.&lt;/p&gt;
&lt;p&gt;Finally, you’ll test your new user interface by adding, editing, and deleting to-do lists and to-do items.&lt;/p&gt;
&lt;p&gt;By completing this project, you’ll learn how to build this app and also understand how the various components fit together. Then, you’ll be ready to undertake your next Django project on your own.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To complete this tutorial, you should be comfortable with the following skills:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/interacting-with-python/#running-a-python-script-from-the-command-line&quot;&gt;Running Python scripts from the command line&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-idle/&quot;&gt;Coding in Python IDLE&lt;/a&gt;, or your favorite code editor &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;Using Python modules and packages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;Understanding object-oriented programming in Python&lt;/a&gt;, including &lt;a href=&quot;https://realpython.com/inheritance-composition-python/&quot;&gt;object inheritance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you don’t have all of the prerequisite knowledge before starting this tutorial, that’s okay. In fact, you might learn more by going ahead and getting started! You can always stop and review the resources linked here if you get stuck.&lt;/p&gt;
&lt;p&gt;You don’t need to have used Django before, because you’ll get step-by-step instructions for installing and using it below. However, if you’re interested in a more detailed introduction to this powerful web framework, there’s a whole range of &lt;a href=&quot;https://realpython.com/tutorials/django/&quot;&gt;Django tutorials&lt;/a&gt; that you can consult.&lt;/p&gt;
&lt;h2 id=&quot;step-1-set-up-your-virtual-environment-and-django&quot;&gt;Step 1: Set Up Your Virtual Environment and Django&lt;a class=&quot;headerlink&quot; href=&quot;#step-1-set-up-your-virtual-environment-and-django&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this step, you’re going to perform a few standard housekeeping tasks that you should only need to do once per Django project. Specifically, you’ll make and activate a virtual environment, install Django, and test that Django is installed correctly.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/django-todo-lists/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/django-todo-lists/ »&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>Exploring the Fibonacci Sequence With Python</title>
      <id>https://realpython.com/courses/python-fibonacci-sequence/</id>
      <link href="https://realpython.com/courses/python-fibonacci-sequence/"/>
      <updated>2022-03-01T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll explore the Fibonacci sequence in Python, which serves as an invaluable springboard into the world of recursion, and learn how to optimize recursive algorithms in the process.</summary>
      <content type="html">
        &lt;p&gt;The &lt;strong&gt;Fibonacci sequence&lt;/strong&gt; is a pretty famous sequence of integer numbers. The sequence comes up naturally in many problems and has a nice recursive definition. Learning how to generate it is an essential step in the pragmatic programmer&amp;rsquo;s journey toward mastering &lt;a href=&quot;https://realpython.com/python-recursion/&quot;&gt;recursion&lt;/a&gt;. In this video course, you&amp;rsquo;ll focus on learning what the Fibonacci sequence is and how to generate it using Python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Generate the Fibonacci sequence using a &lt;strong&gt;recursive algorithm&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Optimize the recursive Fibonacci algorithm using &lt;strong&gt;memoization&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Generate the Fibonacci sequence using an &lt;strong&gt;iterative algorithm&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python&#x27;s urllib.request for HTTP Requests</title>
      <id>https://realpython.com/urllib-request/</id>
      <link href="https://realpython.com/urllib-request/"/>
      <updated>2022-02-28T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll be making HTTP requests with Python&#x27;s built-in urllib.request. You&#x27;ll try out examples and review common errors encountered, all while learning more about HTTP requests and Python in general.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;If you need to make HTTP requests with Python, then you may find yourself directed to the brilliant &lt;a href=&quot;https://docs.python-requests.org/en/latest/&quot;&gt;&lt;code&gt;requests&lt;/code&gt;&lt;/a&gt; library. Though it’s a great library, you may have noticed that it’s not a built-in part of Python. If you prefer, for whatever reason, to limit your dependencies and stick to standard-library Python, then you can reach for &lt;code&gt;urllib.request&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn how to make basic &lt;a href=&quot;https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_and_response_messages_through_connections&quot;&gt;&lt;strong&gt;HTTP requests&lt;/strong&gt;&lt;/a&gt; with &lt;code&gt;urllib.request&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Dive into the nuts and bolts of an &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages&quot;&gt;&lt;strong&gt;HTTP message&lt;/strong&gt;&lt;/a&gt; and how &lt;code&gt;urllib.request&lt;/code&gt; represents it &lt;/li&gt;
&lt;li&gt;Understand how to deal with &lt;strong&gt;character encodings&lt;/strong&gt; of HTTP messages&lt;/li&gt;
&lt;li&gt;Explore some &lt;strong&gt;common errors&lt;/strong&gt; when using &lt;code&gt;urllib.request&lt;/code&gt; and learn how to resolve them&lt;/li&gt;
&lt;li&gt;Dip your toes into the world of &lt;strong&gt;authenticated requests&lt;/strong&gt; with &lt;code&gt;urllib.request&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Understand why both &lt;code&gt;urllib&lt;/code&gt; and the &lt;code&gt;requests&lt;/code&gt; library exist and &lt;strong&gt;when to use one or the other&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you’ve heard of HTTP requests, including &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET&quot;&gt;GET&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST&quot;&gt;POST&lt;/a&gt;, then you’re probably ready for this tutorial. Also, you should’ve already used Python to &lt;a href=&quot;https://realpython.com/read-write-files-python/&quot;&gt;read and write to files&lt;/a&gt;, ideally with a &lt;a href=&quot;https://realpython.com/python-with-statement/&quot;&gt;context manager&lt;/a&gt;, at least once.&lt;/p&gt;
&lt;p&gt;Ultimately, you’ll find that making a request doesn’t have to be a frustrating experience, although it does tend to have that reputation. Many of the issues that you tend to run into are due to the inherent complexity of this marvelous thing called the Internet. The good news is that the &lt;code&gt;urllib.request&lt;/code&gt; module can help to demystify much of this complexity.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Learn More:&lt;/strong&gt; &lt;a href=&quot;&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-newsletter-community&quot; data-focus=&quot;false&quot;&gt;Click here to join 290,000+ Python developers on the Real Python Newsletter&lt;/a&gt; and get new Python tutorials and news that will make you a more effective Pythonista.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;basic-http-get-requests-with-urllibrequest&quot;&gt;Basic HTTP GET Requests With &lt;code&gt;urllib.request&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#basic-http-get-requests-with-urllibrequest&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before diving into the deep end of what an HTTP request is and how it works, you’re going to get your feet wet by making a basic GET request to a &lt;a href=&quot;https://www.iana.org/domains/reserved&quot;&gt;sample URL&lt;/a&gt;. You’ll also make a GET request to a mock &lt;a href=&quot;https://realpython.com/api-integration-in-python/&quot;&gt;REST API&lt;/a&gt; for some &lt;a href=&quot;https://realpython.com/python-json/&quot;&gt;JSON&lt;/a&gt; data. In case you’re wondering about POST Requests, you’ll be covering them &lt;a href=&quot;#post-requests-with-urllibrequest&quot;&gt;later in the tutorial&lt;/a&gt;, once you have some more knowledge of &lt;code&gt;urllib.request&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;Beware:&lt;/strong&gt; Depending on your exact setup, you may find that some of these examples don’t work. If so, skip ahead to the section on common &lt;a href=&quot;#common-urllibrequest-troubles&quot;&gt;&lt;code&gt;urllib.request&lt;/code&gt; errors&lt;/a&gt; for troubleshooting.&lt;/p&gt;
&lt;p&gt;If you’re running into a problem that’s not covered there, be sure to comment below with a precise and reproducible example.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To get started, you’ll make a request to &lt;code&gt;www.example.com&lt;/code&gt;, and the server will return an HTTP message. Ensure that you’re using Python 3 or above, and then use the &lt;code&gt;urlopen()&lt;/code&gt; function from &lt;code&gt;urllib.request&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;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;urllib.request&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&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;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://www.example.com&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&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;body&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&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;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;b&#x27;&amp;lt;!doctype html&amp;gt;&#x27;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you import &lt;code&gt;urlopen()&lt;/code&gt; from &lt;code&gt;urllib.request&lt;/code&gt;. Using the &lt;a href=&quot;https://realpython.com/python-with-statement/&quot;&gt;context manager&lt;/a&gt; &lt;code&gt;with&lt;/code&gt;, you make a request and receive a response with &lt;code&gt;urlopen()&lt;/code&gt;. Then you read the body of the response and close the response object. With that, you display the first fifteen positions of the body, noting that it looks like an HTML document.&lt;/p&gt;
&lt;p&gt;There you are! You’ve successfully made a request, and you received a response. By inspecting the content, you can tell that it’s likely an HTML document. Note that the printed output of the body is preceded by &lt;code&gt;b&lt;/code&gt;. This indicates a &lt;a href=&quot;https://docs.python.org/3/reference/lexical_analysis.html#strings&quot;&gt;bytes literal&lt;/a&gt;, which you may need to decode. Later in the tutorial, you’ll learn how to turn bytes into a &lt;a href=&quot;#going-from-bytes-to-strings&quot;&gt;string&lt;/a&gt;, write them to a &lt;a href=&quot;#going-from-bytes-to-file&quot;&gt;file&lt;/a&gt;, or parse them into a &lt;a href=&quot;#going-from-bytes-to-dictionary&quot;&gt;dictionary&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The process is only slightly different if you want to make calls to REST APIs to get JSON data. In the following example, you’ll make a request to &lt;a href=&quot;https://jsonplaceholder.typicode.com&quot;&gt;{JSON}Placeholder&lt;/a&gt; for some fake to-do data:&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;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;urllib.request&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;json&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;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://jsonplaceholder.typicode.com/todos/1&quot;&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;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&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;body&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&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;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;todo_item&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loads&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&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;todo_item&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;{&#x27;userId&#x27;: 1, &#x27;id&#x27;: 1, &#x27;title&#x27;: &#x27;delectus aut autem&#x27;, &#x27;completed&#x27;: False}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you’re doing pretty much the same as in the previous example. But in this one, you import &lt;code&gt;urllib.request&lt;/code&gt; &lt;em&gt;and&lt;/em&gt; &lt;code&gt;json&lt;/code&gt;, using the &lt;code&gt;json.loads()&lt;/code&gt; function with &lt;code&gt;body&lt;/code&gt; to decode and parse the returned JSON bytes into a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;Python dictionary&lt;/a&gt;. Voila!&lt;/p&gt;
&lt;p&gt;If you’re lucky enough to be using error-free &lt;a href=&quot;https://en.wikipedia.org/wiki/Web_API#Endpoints&quot;&gt;endpoints&lt;/a&gt;, such as the ones in these examples, then maybe the above is all that you need from &lt;code&gt;urllib.request&lt;/code&gt;. Then again, you may find that it’s not enough.&lt;/p&gt;
&lt;p&gt;Now, before doing some &lt;code&gt;urllib.request&lt;/code&gt; troubleshooting, you’ll first gain an understanding of the underlying structure of HTTP messages and learn how &lt;code&gt;urllib.request&lt;/code&gt; handles them. This understanding will provide a solid foundation for troubleshooting many different kinds of issues.&lt;/p&gt;
&lt;h2 id=&quot;the-nuts-and-bolts-of-http-messages&quot;&gt;The Nuts and Bolts of HTTP Messages&lt;a class=&quot;headerlink&quot; href=&quot;#the-nuts-and-bolts-of-http-messages&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To understand some of the issues that you may encounter when using &lt;code&gt;urllib.request&lt;/code&gt;, you’ll need to examine how a response is represented by &lt;code&gt;urllib.request&lt;/code&gt;. To do that, you’ll benefit from a high-level overview of what an &lt;strong&gt;HTTP message&lt;/strong&gt; is, which is what you’ll get in this section.&lt;/p&gt;
&lt;p&gt;Before the high-level overview, a quick note on reference sources. If you want to get into the technical weeds, the &lt;a href=&quot;https://www.ietf.org/&quot;&gt;Internet Engineering Task Force (IETF)&lt;/a&gt; has an extensive set of &lt;a href=&quot;https://www.ietf.org/standards/rfcs/&quot;&gt;Request for Comments (RFC)&lt;/a&gt; documents. These documents end up becoming the actual specifications for things like HTTP messages. &lt;a href=&quot;https://datatracker.ietf.org/doc/html/rfc7230&quot;&gt;RFC 7230, part 1: Message Syntax and Routing&lt;/a&gt;, for example, is all about the HTTP message.&lt;/p&gt;
&lt;p&gt;If you’re looking for some reference material that’s a bit easier to digest than RFCs, then the &lt;a href=&quot;https://developer.mozilla.org/&quot;&gt;Mozilla Developer Network (MDN)&lt;/a&gt; has a great range of reference articles. For example, their article on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages&quot;&gt;HTTP messages&lt;/a&gt;, while still technical, is a lot more digestible.&lt;/p&gt;
&lt;p&gt;Now that you know about these essential sources of reference information, in the next section you’ll get a beginner-friendly overview of HTTP messages.&lt;/p&gt;
&lt;h3 id=&quot;understanding-what-an-http-message-is&quot;&gt;Understanding What an HTTP Message Is&lt;a class=&quot;headerlink&quot; href=&quot;#understanding-what-an-http-message-is&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In a nutshell, an HTTP message can be understood as text, transmitted as a stream of &lt;a href=&quot;https://en.wikipedia.org/wiki/Byte&quot;&gt;bytes&lt;/a&gt;, structured to follow the guidelines specified by RFC 7230. A decoded HTTP message can be as simple as two lines:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/urllib-request/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/urllib-request/ »&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 #99: OAuth 2 and Authentication Choices for Your Python Project</title>
      <id>https://realpython.com/podcasts/rpp/99/</id>
      <link href="https://realpython.com/podcasts/rpp/99/"/>
      <updated>2022-02-25T12:00:00+00:00</updated>
      <summary>Have you thought about what authentication system you want to use for your Python project? Should you use an existing Python library or a third-party service? This week on the show, Dan Moore is here to talk about authentication systems and OAuth 2.</summary>
      <content type="html">
        &lt;p&gt;Have you thought about what authentication system you want to use for your Python project? Should you use an existing Python library or a third-party service? This week on the show, Dan Moore is here to talk about authentication systems and OAuth 2.&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>Starting With Linear Regression in Python</title>
      <id>https://realpython.com/courses/python-linear-regression/</id>
      <link href="https://realpython.com/courses/python-linear-regression/"/>
      <updated>2022-02-22T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll get started with linear regression in Python. Linear regression is one of the fundamental statistical and machine learning techniques, and Python is a popular choice for machine learning.</summary>
      <content type="html">
        &lt;p&gt;We&amp;rsquo;re living in the era of large amounts of &lt;a href=&quot;https://realpython.com/tutorials/data-science/&quot;&gt;data&lt;/a&gt;, powerful computers, and &lt;a href=&quot;https://realpython.com/python-ai-neural-network/&quot;&gt;artificial intelligence&lt;/a&gt;. This is just the beginning. &lt;a href=&quot;https://realpython.com/data-science-podcasts/&quot;&gt;Data science&lt;/a&gt; and machine learning are driving image recognition, autonomous vehicle development, decisions in the financial and energy sectors, advances in medicine, the rise of social networks, and more. Linear regression is an important part of this.&lt;/p&gt;
&lt;p&gt;Linear regression is one of the fundamental statistical and machine learning techniques. Whether you want to do &lt;a href=&quot;https://realpython.com/python-statistics/&quot;&gt;statistics&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/tutorials/machine-learning/&quot;&gt;machine learning&lt;/a&gt;, or scientific computing, there&amp;rsquo;s a good chance that you&amp;rsquo;ll need it. It&amp;rsquo;s advisable to learn it first and then proceed toward more complex methods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this video course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What linear regression is&lt;/li&gt;
&lt;li&gt;What linear regression is used for&lt;/li&gt;
&lt;li&gt;How linear regression works&lt;/li&gt;
&lt;li&gt;How to implement linear regression in Python, step by step&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #98: Drawing Fractals With Python and Working With a Weather API</title>
      <id>https://realpython.com/podcasts/rpp/98/</id>
      <link href="https://realpython.com/podcasts/rpp/98/"/>
      <updated>2022-02-18T12:00:00+00:00</updated>
      <summary>Have you been wanting to explore fractals and complex numbers in Python? Would you like to practice working with APIs in Python through a new project? This week on the show, Christopher Trudeau is here, and he&#x27;s taking on the task of curating new issues of PyCoder&#x27;s Weekly going forward. He&#x27;ll be joining me as a cohost every other week and bringing a fresh batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Have you been wanting to explore fractals and complex numbers in Python? Would you like to practice working with APIs in Python through a new project? This week on the show, Christopher Trudeau is here, and he&#x27;s taking on the task of curating new issues of PyCoder&#x27;s Weekly going forward. He&#x27;ll be joining me as a cohost every other week and bringing a fresh batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python any(): Powered Up Boolean Function</title>
      <id>https://realpython.com/courses/python-any-boolean-function/</id>
      <link href="https://realpython.com/courses/python-any-boolean-function/"/>
      <updated>2022-02-15T14:00:00+00:00</updated>
      <summary>If you&#x27;ve ever wondered how to simplify complex conditionals by determining if at least one in a series of conditions is true, then look no further. This video course will teach you all about how to use any() in Python to do just that.</summary>
      <content type="html">
        &lt;p&gt;As a Python programmer, you&amp;rsquo;ll frequently deal with &lt;a href=&quot;https://realpython.com/python-boolean/&quot;&gt;Booleans&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-conditional-statements/&quot;&gt;conditional statements&lt;/a&gt;&amp;mdash;sometimes very complex ones. In those situations, you may need to rely on tools that can simplify logic and consolidate information. Fortunately,  &lt;strong&gt;&lt;code&gt;any()&lt;/code&gt;&lt;/strong&gt; in Python is such a tool. It looks through the elements in an iterable and returns a single value indicating whether any element is true in a Boolean context, or &lt;strong&gt;truthy.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;any()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;not any()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Elimate long &lt;strong&gt;&lt;code&gt;or&lt;/code&gt; chains&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;any()&lt;/code&gt; with &lt;strong&gt;list comprehensions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Evalute values&lt;/strong&gt; that aren&amp;rsquo;t explicitly &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Distinguish between &lt;strong&gt;&lt;code&gt;any()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;or&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;short-circuiting&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #97: Improving Your Django and Python Developer Experience</title>
      <id>https://realpython.com/podcasts/rpp/97/</id>
      <link href="https://realpython.com/podcasts/rpp/97/"/>
      <updated>2022-02-11T12:00:00+00:00</updated>
      <summary>How often have you thought about your Developer Experience (DX)? How do you improve your workflow, find documentation, and simplify code formatting? This week on the show, Adam Johnson is here to talk about his new book, &quot;Boost Your Django DX.&quot;</summary>
      <content type="html">
        &lt;p&gt;How often have you thought about your Developer Experience (DX)? How do you improve your workflow, find documentation, and simplify code formatting? This week on the show, Adam Johnson is here to talk about his new book, &quot;Boost Your Django DX.&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>Defining Python Functions With Optional Arguments</title>
      <id>https://realpython.com/courses/defining-python-functions-with-optional-arguments/</id>
      <link href="https://realpython.com/courses/defining-python-functions-with-optional-arguments/"/>
      <updated>2022-02-08T14:00:00+00:00</updated>
      <summary>In this video course, you&#x27;ll learn about Python optional arguments and how to define functions with default values. You&#x27;ll also learn how to create functions that accept any number of arguments using args and kwargs.</summary>
      <content type="html">
        &lt;p&gt;Defining your own functions is an essential skill for writing clean and effective code. In this tutorial, you&amp;rsquo;ll explore the techniques you have available for defining Python functions that take optional arguments. When you master Python optional arguments, you&amp;rsquo;ll be able to define functions that are more powerful and more flexible.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Distinguish between &lt;strong&gt;parameters&lt;/strong&gt; and &lt;strong&gt;arguments&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Define functions with &lt;strong&gt;optional arguments&lt;/strong&gt; and &lt;strong&gt;default parameter values&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Define functions using &lt;strong&gt;&lt;code&gt;args&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;kwargs&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Deal with &lt;strong&gt;error messages&lt;/strong&gt; about optional arguments&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #96: Manipulating and Analyzing Audio in Python</title>
      <id>https://realpython.com/podcasts/rpp/96/</id>
      <link href="https://realpython.com/podcasts/rpp/96/"/>
      <updated>2022-02-04T12:00:00+00:00</updated>
      <summary>Would you like to experiment with analyzing or manipulating audio with Python? This week on the show, we have Braden Riggs from DolbyIO to discuss extracting audio features and Python libraries for reshaping audio. Braden shares techniques from his recent talk at PyData Global, &quot;Unlocking More From Your Audio Data!&quot;</summary>
      <content type="html">
        &lt;p&gt;Would you like to experiment with analyzing or manipulating audio with Python? This week on the show, we have Braden Riggs from DolbyIO to discuss extracting audio features and Python libraries for reshaping audio. Braden shares techniques from his recent talk at PyData Global, &quot;Unlocking More From Your Audio Data!&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>Python&#x27;s len() Function</title>
      <id>https://realpython.com/courses/pythons-len-function/</id>
      <link href="https://realpython.com/courses/pythons-len-function/"/>
      <updated>2022-02-01T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn how and when to use the len() Python function. You&#x27;ll also learn how to customize your class definitions so that objects of a user-defined class can be used as arguments in len().</summary>
      <content type="html">
        &lt;p&gt;In many situations, you&amp;rsquo;ll need to find the number of items stored in a data structure. Python&amp;rsquo;s built-in function &lt;code&gt;len()&lt;/code&gt; is the tool that will help you with this task.&lt;/p&gt;
&lt;p&gt;There are some cases in which the use of &lt;code&gt;len()&lt;/code&gt; is straightforward. However, there are other times when you&amp;rsquo;ll need to understand how this function works in more detail and how to apply it to different data types.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Find the length of  &lt;strong&gt;built-in data types&lt;/strong&gt; using &lt;code&gt;len()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;len()&lt;/code&gt; with &lt;strong&gt;third-party data types&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Provide support for &lt;code&gt;len()&lt;/code&gt; with &lt;strong&gt;user-defined classes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #95: What Is a JIT and How Can Pyjion Speed Up Your Python?</title>
      <id>https://realpython.com/podcasts/rpp/95/</id>
      <link href="https://realpython.com/podcasts/rpp/95/"/>
      <updated>2022-01-28T12:00:00+00:00</updated>
      <summary>How can you can speed up Python? Have you thought of using a JIT (Just-In-Time Compiler)? This week on the show, we have Real Python author and previous guest Anthony Shaw to talk about his project Pyjion, a drop-in JIT compiler for CPython 3.10.</summary>
      <content type="html">
        &lt;p&gt;How can you can speed up Python? Have you thought of using a JIT (Just-In-Time Compiler)? This week on the show, we have Real Python author and previous guest Anthony Shaw to talk about his project Pyjion, a drop-in JIT compiler for CPython 3.10.&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>Looping With Python enumerate()</title>
      <id>https://realpython.com/courses/looping-with-python-enumerate/</id>
      <link href="https://realpython.com/courses/looping-with-python-enumerate/"/>
      <updated>2022-01-25T14:00:00+00:00</updated>
      <summary>Once you learn about for loops in Python, you know that using an index to access items in a sequence isn&#x27;t very Pythonic. So what do you do when you need that index value? In this course, you&#x27;ll learn all about Python&#x27;s built-in enumerate(), where it&#x27;s used, and how you can emulate its behavior.</summary>
      <content type="html">
        &lt;p&gt;In Python, a &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/a&gt; is usually written as a loop over an iterable object. This means that you don&amp;rsquo;t need a counting variable to access items in the iterable. Sometimes, though, you do want to have a variable that changes on each loop iteration. Rather than creating and incrementing a variable yourself, you can use Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;enumerate()&lt;/code&gt;&lt;/strong&gt; to get a counter and the value from the iterable at the same time!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll see how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;enumerate()&lt;/code&gt;&lt;/strong&gt; to get a counter in a loop&lt;/li&gt;
&lt;li&gt;Apply &lt;code&gt;enumerate()&lt;/code&gt; to &lt;strong&gt;display item counts&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implement your own &lt;strong&gt;equivalent function&lt;/strong&gt; to &lt;code&gt;enumerate()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unpack values&lt;/strong&gt; returned by &lt;code&gt;enumerate()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  

</feed>
