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

  
    <entry>
      <title>Handling SQL Databases With PyQt: The Basics</title>
      <id>https://realpython.com/python-pyqt-database/</id>
      <link href="https://realpython.com/python-pyqt-database/"/>
      <updated>2020-12-02T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you’ll learn how to use PyQt&#x27;s built-in SQL support to create GUI applications that effectively manage SQL databases.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Building applications that use an &lt;a href=&quot;https://realpython.com/python-sql-libraries/&quot;&gt;SQL database&lt;/a&gt; is a fairly common programming task. SQL databases are everywhere and have great support in Python. In GUI programming, PyQt provides robust and cross-platform &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtsql/qtsql-module.html&quot;&gt;SQL database support&lt;/a&gt; that allows you to create, connect to, and manage your databases consistently.&lt;/p&gt;
&lt;p&gt;PyQt’s SQL support fully integrates with its &lt;a href=&quot;https://doc.qt.io/qt-5/model-view-programming.html#the-model-view-architecture&quot;&gt;Model-View architecture&lt;/a&gt; to help you in the process of building database applications. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use PyQt’s &lt;strong&gt;SQL support&lt;/strong&gt; to reliably connect to a database&lt;/li&gt;
&lt;li&gt;Execute &lt;strong&gt;SQL queries&lt;/strong&gt; on a database using PyQt&lt;/li&gt;
&lt;li&gt;Use PyQt’s &lt;strong&gt;Model-View architecture&lt;/strong&gt; in database applications&lt;/li&gt;
&lt;li&gt;Display and edit data using different PyQt &lt;strong&gt;widgets&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The examples in this tutorial require a basic knowledge of the SQL language, especially of the &lt;a href=&quot;https://realpython.com/python-sqlite-sqlalchemy/&quot;&gt;SQLite&lt;/a&gt; database management system. Some previous knowledge of &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/&quot;&gt;GUI programming with Python and PyQt&lt;/a&gt; will also be helpful.&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;connecting-pyqt-to-an-sql-database&quot;&gt;Connecting PyQt to an SQL Database&lt;a class=&quot;headerlink&quot; href=&quot;#connecting-pyqt-to-an-sql-database&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Connecting an application to a &lt;a href=&quot;https://en.wikipedia.org/wiki/Relational_database&quot;&gt;relational database&lt;/a&gt; and getting the application to create, read, update, and delete the data stored in that database is a common task in programming. Relational databases are generally organized into a set of &lt;strong&gt;tables&lt;/strong&gt;, or &lt;strong&gt;relations&lt;/strong&gt;. A given &lt;a href=&quot;https://en.wikipedia.org/wiki/Row_(database)&quot;&gt;row&lt;/a&gt; in a table is referred to as a &lt;strong&gt;record&lt;/strong&gt; or &lt;strong&gt;tuple&lt;/strong&gt;, and a &lt;a href=&quot;https://en.wikipedia.org/wiki/Column_(database)&quot;&gt;column&lt;/a&gt; is referred to as an &lt;strong&gt;attribute&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The term &lt;strong&gt;field&lt;/strong&gt; is &lt;a href=&quot;https://en.wikipedia.org/wiki/Column_(database)#Field&quot;&gt;commonly used&lt;/a&gt; to identify a single piece of data stored in a cell of a given record in a table. On the other hand, the term &lt;strong&gt;field name&lt;/strong&gt; is used to identify the name of a column.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Each column stores a specific kind of information, such as a names, dates, or numbers. Each row represents a set of closely related data, and every row has the same general structure. For example, in a database that stores data about the employees in a company, a specific row represents an individual employee.&lt;/p&gt;
&lt;p&gt;Most relational database systems use &lt;a href=&quot;https://en.wikipedia.org/wiki/SQL&quot;&gt;SQL (structured query language)&lt;/a&gt; for querying, manipulating, and maintaining the data held in the database. SQL is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Declarative_programming&quot;&gt;declarative&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Domain-specific_language&quot;&gt;domain-specific&lt;/a&gt; programming language specially designed for communicating with databases.&lt;/p&gt;
&lt;p&gt;Relational database systems and SQL are widely used nowadays. You’ll find several different database management systems, such as &lt;a href=&quot;https://www.sqlite.org/about.html&quot;&gt;SQLite&lt;/a&gt;, &lt;a href=&quot;https://www.postgresql.org/about/&quot;&gt;PostgreSQL&lt;/a&gt;, &lt;a href=&quot;https://dev.mysql.com/doc/&quot;&gt;MySQL&lt;/a&gt;, &lt;a href=&quot;https://mariadb.org/about/&quot;&gt;MariaDB&lt;/a&gt;, and many others. You can connect Python to any of these database systems using a dedicated Python SQL library.&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; Even though PyQt’s built-in SQL support is the preferred option for managing SQL databases in PyQt, you can also use any other library to handle the database connection. Some of these libraries include &lt;a href=&quot;https://realpython.com/python-sqlite-sqlalchemy/#working-with-sqlalchemy-and-python-objects&quot;&gt;SQLAlchemy&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/pandas-read-write-files/#sql-files&quot;&gt;pandas&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-sqlite-sqlalchemy/#using-sqlite-to-persist-data&quot;&gt;SQLite&lt;/a&gt;, and so on.&lt;/p&gt;
&lt;p&gt;However, using a different library to manage your databases has some drawbacks. You won’t be able to take advantage of the integration between PyQt’s SQL classes and the Model-View architecture. In addition, you’ll be adding extra dependencies to your application.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;When it comes to GUI programming with Python and PyQt, PyQt provides a robust &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtsql/qtsql-module.html&quot;&gt;set of classes for working with SQL databases&lt;/a&gt;. This set of classes will be your best ally when you need to connect your application to an SQL database.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Unfortunately, &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/index.html&quot;&gt;PyQt5’s official documentation&lt;/a&gt; has some incomplete sections. To work around this, you can check out the &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt4/&quot;&gt;PyQt4 documentation&lt;/a&gt;, the &lt;a href=&quot;https://doc.qt.io/qtforpython/&quot;&gt;Qt For Python’s documentation&lt;/a&gt;, or the original &lt;a href=&quot;https://doc.qt.io/&quot;&gt;Qt documentation&lt;/a&gt;. In this tutorial, some links take you to the original Qt documentation, which is a better source of information in most cases.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In this tutorial, you’ll learn the basics of how to use PyQt’s SQL support to create GUI applications that reliably interact with relational databases to read, write, delete, and display data.&lt;/p&gt;
&lt;h3 id=&quot;creating-a-database-connection&quot;&gt;Creating a Database Connection&lt;a class=&quot;headerlink&quot; href=&quot;#creating-a-database-connection&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Connecting your applications to a physical SQL database is an important step in the process of developing database applications with PyQt. To perform this step successfully, you need some general information about how your database is set up.&lt;/p&gt;
&lt;p&gt;For example, you need to know what database management system your database is built on, and you might also need to have a username, a password, a hostname, and so on.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll use &lt;a href=&quot;https://sqlite.org/about.html&quot;&gt;SQLite 3&lt;/a&gt;, which is a well-tested database system with support on all platforms and minimal configuration requirements. SQLite allows you to read and write directly to databases in your local disk without the need for a separate server process. That makes it a user-friendly option for learning database application development.&lt;/p&gt;
&lt;p&gt;Another advantage of using SQLite is that the library comes shipped with Python and also with PyQt, so you don’t need to install anything else to start working with it.&lt;/p&gt;
&lt;p&gt;In PyQt, you can create a database connection by using the &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtsql/qsqldatabase.html&quot;&gt;&lt;code&gt;QSqlDatabase&lt;/code&gt;&lt;/a&gt; class. This class represents a connection and provides an interface for accessing the database. To create a connection, just call &lt;a href=&quot;https://doc.qt.io/qt-5/qsqldatabase.html#addDatabase&quot;&gt;&lt;code&gt;.addDatabase()&lt;/code&gt;&lt;/a&gt; on &lt;code&gt;QSqlDatabase&lt;/code&gt;. This &lt;a href=&quot;https://realpython.com/instance-class-and-static-methods-demystified/&quot;&gt;static method&lt;/a&gt; takes an &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtsql/qsqldriver.html&quot;&gt;SQL driver&lt;/a&gt; and an optional connection name as arguments and &lt;a href=&quot;https://realpython.com/python-return-statement/&quot;&gt;returns&lt;/a&gt; a database connection:&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;n&quot;&gt;QSqlDatabase&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addDatabase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;driver&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;connectionName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;QSqlDatabase&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;defaultConnection&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 first argument, &lt;code&gt;driver&lt;/code&gt;, is a required argument that holds a string containing the name of a &lt;a href=&quot;https://doc.qt.io/qt-5/sql-driver.html#supported-databases&quot;&gt;PyQt-supported SQL driver&lt;/a&gt;. The second argument, &lt;code&gt;connectionName&lt;/code&gt;, is an optional argument that holds a string with the name of the connection. &lt;code&gt;connectionName&lt;/code&gt; defaults to &lt;code&gt;QSqlDatabase.defaultConnection&lt;/code&gt;, which normally holds the string &lt;code&gt;&quot;qt_sql_default_connection&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you already have a connection called &lt;code&gt;connectionName&lt;/code&gt;, then that connection is removed and replaced with a new connection, and &lt;code&gt;.addDatabase()&lt;/code&gt; returns the newly added database connection back to the caller.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-pyqt-database/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-pyqt-database/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How Python Manages Memory</title>
      <id>https://realpython.com/courses/how-python-manages-memory/</id>
      <link href="https://realpython.com/courses/how-python-manages-memory/"/>
      <updated>2020-12-01T14:00:00+00:00</updated>
      <summary>Get ready for a deep dive into the internals of Python to understand how it handles memory management. By the end of this course, you’ll know more about low-level computing, understand how Python abstracts lower-level operations, and find out about Python’s internal memory management algorithms.</summary>
      <content type="html">
        &lt;p&gt;Ever wonder how Python handles your data behind the scenes? How are your &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variables&lt;/a&gt; stored in memory? When do they get deleted?&lt;/p&gt;
&lt;p&gt;In this course, we&amp;rsquo;re going to do a deep dive into the internals of Python to understand how it handles memory management.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this course, you&amp;rsquo;ll:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn more about low-level computing, specifically as relates to memory&lt;/li&gt;
&lt;li&gt;Understand how Python abstracts lower-level operations&lt;/li&gt;
&lt;li&gt;Learn about Python&amp;rsquo;s internal memory management algorithms&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>np.linspace(): Create Evenly or Non-Evenly Spaced Arrays</title>
      <id>https://realpython.com/np-linspace-numpy/</id>
      <link href="https://realpython.com/np-linspace-numpy/"/>
      <updated>2020-11-30T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use NumPy&#x27;s np.linspace() effectively to create an evenly or non-evenly spaced range of numbers. You&#x27;ll explore several practical examples of the function&#x27;s many uses in numerical applications.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When you’re working with numerical applications using &lt;a href=&quot;https://realpython.com/numpy-array-programming/&quot;&gt;NumPy&lt;/a&gt;, you often need to create an array of &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;. In many cases you want the numbers to be evenly spaced, but there are also times when you may need non-evenly spaced numbers. One of the key tools you can use in both situations is &lt;strong&gt;&lt;code&gt;np.linspace()&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In its basic form, &lt;code&gt;np.linspace()&lt;/code&gt; can seem relatively straightforward to use. However, it’s an essential part of the numerical programming toolkit. It’s both very versatile and powerful. In this tutorial, you’ll find out how to use this function effectively. &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 an evenly or non-evenly spaced &lt;strong&gt;range of numbers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Decide when to use &lt;strong&gt;&lt;code&gt;np.linspace()&lt;/code&gt;&lt;/strong&gt; instead of alternative tools&lt;/li&gt;
&lt;li&gt;Use the required and optional &lt;strong&gt;input parameters&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Create arrays with &lt;strong&gt;two or more dimensions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Represent &lt;strong&gt;mathematical functions&lt;/strong&gt; in discrete form&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This tutorial assumes you’re already familiar with the basics of NumPy and the &lt;a href=&quot;https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html&quot;&gt;&lt;code&gt;ndarray&lt;/code&gt;&lt;/a&gt; data type. You’ll start by learning about various ways of creating a range of numbers in Python. Then you’ll take a closer look at all the ways of using &lt;code&gt;np.linspace()&lt;/code&gt; and how you can use it effectively in your programs.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;#&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-numpy-learning-guide&quot; data-focus=&quot;false&quot;&gt;Click here to get access to a free NumPy Resources Guide&lt;/a&gt; that points you to the best tutorials, videos, and books for improving your NumPy skills.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;creating-ranges-of-numbers-with-even-spacing&quot;&gt;Creating Ranges of Numbers With Even Spacing&lt;a class=&quot;headerlink&quot; href=&quot;#creating-ranges-of-numbers-with-even-spacing&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are several ways in which you can create a range of &lt;strong&gt;evenly spaced numbers&lt;/strong&gt; in Python. &lt;code&gt;np.linspace()&lt;/code&gt; allows you to do this and to customize the range to fit your specific needs, but it’s not the only way to create a range of numbers. In the next section, you’ll learn how to use &lt;code&gt;np.linspace()&lt;/code&gt; before comparing it with other ways of creating ranges of evenly spaced numbers.&lt;/p&gt;
&lt;h3 id=&quot;using-nplinspace&quot;&gt;Using &lt;code&gt;np.linspace()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#using-nplinspace&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;np.linspace()&lt;/code&gt; has two required parameters, &lt;strong&gt;&lt;code&gt;start&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;stop&lt;/code&gt;&lt;/strong&gt;, which you can use to set the beginning and end of the range:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linspace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([ 1.        ,  1.18367347,  1.36734694,  1.55102041,  1.73469388,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        1.91836735,  2.10204082,  2.28571429,  2.46938776,  2.65306122,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        2.83673469,  3.02040816,  3.20408163,  3.3877551 ,  3.57142857,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        3.75510204,  3.93877551,  4.12244898,  4.30612245,  4.48979592,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        4.67346939,  4.85714286,  5.04081633,  5.2244898 ,  5.40816327,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        5.59183673,  5.7755102 ,  5.95918367,  6.14285714,  6.32653061,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        6.51020408,  6.69387755,  6.87755102,  7.06122449,  7.24489796,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        7.42857143,  7.6122449 ,  7.79591837,  7.97959184,  8.16326531,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        8.34693878,  8.53061224,  8.71428571,  8.89795918,  9.08163265,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        9.26530612,  9.44897959,  9.63265306,  9.81632653, 10.        ])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This code returns an &lt;a href=&quot;https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html&quot;&gt;&lt;code&gt;ndarray&lt;/code&gt;&lt;/a&gt; with equally spaced intervals between the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;stop&lt;/code&gt; values. This is a &lt;strong&gt;vector space&lt;/strong&gt;, also called a &lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_space_(geometry)&quot;&gt;linear space&lt;/a&gt;, which is where the name &lt;code&gt;linspace&lt;/code&gt; comes from.&lt;/p&gt;
&lt;p&gt;Note that the value &lt;code&gt;10&lt;/code&gt; is included in the output array. The function returns a &lt;strong&gt;closed range&lt;/strong&gt;, one that includes the endpoint, by default. This is contrary to what you might expect from Python, in which the end of a range usually isn’t included. This break with convention isn’t an oversight. You’ll see later on that this is usually what you want when using this function.&lt;/p&gt;
&lt;p&gt;The array in the example above is of length &lt;code&gt;50&lt;/code&gt;, which is the default number. In most cases, you’ll want to set your own number of values in the array. You can do so with the optional parameter &lt;strong&gt;&lt;code&gt;num&lt;/code&gt;&lt;/strong&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;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linspace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10.])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The output array in this instance contains &lt;code&gt;10&lt;/code&gt; equally spaced values between &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;10&lt;/code&gt;, which is just the numbers from &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;10&lt;/code&gt;. Here’s another example:&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;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linspace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([-10.        ,  -9.16666667,  -8.33333333,  -7.5       ,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        -6.66666667,  -5.83333333,  -5.        ,  -4.16666667,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        -3.33333333,  -2.5       ,  -1.66666667,  -0.83333333,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;         0.        ,   0.83333333,   1.66666667,   2.5       ,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;         3.33333333,   4.16666667,   5.        ,   5.83333333,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;         6.66666667,   7.5       ,   8.33333333,   9.16666667,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        10.        ])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the example above, you create a linear space with &lt;code&gt;25&lt;/code&gt; values between &lt;code&gt;-10&lt;/code&gt; and &lt;code&gt;10&lt;/code&gt;. You use the &lt;code&gt;num&lt;/code&gt; parameter as a &lt;strong&gt;positional argument&lt;/strong&gt;, without explicitly mentioning its name in the function call. This is the form you’re likely to use most often.&lt;/p&gt;
&lt;h3 id=&quot;using-range-and-list-comprehensions&quot;&gt;Using &lt;code&gt;range()&lt;/code&gt; and List Comprehensions&lt;a class=&quot;headerlink&quot; href=&quot;#using-range-and-list-comprehensions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Let’s take a step back and look at what other tools you could use to create an evenly spaced range of numbers. The most straightforward option that Python offers is the built-in &lt;a href=&quot;https://realpython.com/python-range/&quot;&gt;&lt;code&gt;range()&lt;/code&gt;&lt;/a&gt;. The function call &lt;code&gt;range(10)&lt;/code&gt; returns an object that produces the sequence from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;9&lt;/code&gt;, which is an evenly spaced range of numbers.&lt;/p&gt;
&lt;p&gt;For many numerical applications, the fact that &lt;code&gt;range()&lt;/code&gt; is limited to integers is too restrictive. Of the examples shown above, only &lt;code&gt;np.linspace(1, 10, 10)&lt;/code&gt; can be accomplished with &lt;code&gt;range()&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;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The values returned by &lt;code&gt;range()&lt;/code&gt;, when converted explicitly into a list, are the same as those returned by the NumPy version, except that they’re integers instead of floats.&lt;/p&gt;
&lt;p&gt;You can still use &lt;code&gt;range()&lt;/code&gt; with &lt;a href=&quot;https://realpython.com/list-comprehension-python/&quot;&gt;list comprehensions&lt;/a&gt; to create non-integer ranges:&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;step&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Divide the range into 24 intervals&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;step&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;interval&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interval&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[-10.0, -9.166666666666666, -8.333333333333334, -7.5,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; -6.666666666666666, -5.833333333333333, -5.0, -4.166666666666666,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; -3.333333333333333, -2.5, -1.666666666666666, -0.8333333333333321,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; 0.0, 0.8333333333333339, 1.6666666666666679, 2.5,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; 3.333333333333334, 4.166666666666668, 5.0, 5.833333333333334,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; 6.666666666666668, 7.5, 8.333333333333336, 9.166666666666668, 10.0]&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/np-linspace-numpy/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/np-linspace-numpy/ »&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 #37: Teaching Python and Finding Resources for Students</title>
      <id>https://realpython.com/podcasts/rpp/37/</id>
      <link href="https://realpython.com/podcasts/rpp/37/"/>
      <updated>2020-11-27T12:00:00+00:00</updated>
      <summary>One of the best ways to learn something well is to teach it. This week on the show, we have Kelly Schuster-Paredes and Sean Tibor from the Teaching Python podcast.

Sean and Kelly teach middle school students Python and share their art and science of teaching Python on their podcast. They wanted to come on the show to talk about the Real Python articles, quizzes, and other resources they use when teaching their students.</summary>
      <content type="html">
        &lt;p&gt;One of the best ways to learn something well is to teach it. This week on the show, we have Kelly Schuster-Paredes and Sean Tibor from the Teaching Python podcast.

Sean and Kelly teach middle school students Python and share their art and science of teaching Python on their podcast. They wanted to come on the show to talk about the Real Python articles, quizzes, and other resources they use when teaching their students.&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>PyQt Layouts: Create Professional-Looking GUI Applications</title>
      <id>https://realpython.com/python-pyqt-layout/</id>
      <link href="https://realpython.com/python-pyqt-layout/"/>
      <updated>2020-11-25T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you’ll learn how to use PyQt layouts to arrange and manage the graphical components on your GUI applications. With the help of PyQt&#x27;s layout managers, you&#x27;ll be able to create polished and professional GUIs with minimal effort.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;PyQt’s &lt;a href=&quot;https://doc.qt.io/qt-5/layout.html&quot;&gt;layout managers&lt;/a&gt; provide a user-friendly and productive way of arranging graphical components, or &lt;strong&gt;widgets&lt;/strong&gt;, on a GUI. Laying out widgets properly will make your &lt;a href=&quot;https://realpython.com/learning-paths/python-gui-programming/&quot;&gt;GUI applications&lt;/a&gt; look polished and professional. Learning to do so efficiently and effectively is a fundamental skill for you to get up and running with GUI application development using Python and PyQt.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What the benefits are of using PyQt’s &lt;strong&gt;layout managers&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;How to programmatically &lt;strong&gt;lay out widgets&lt;/strong&gt; on a GUI using PyQt’s layout managers &lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;select the right layout manager&lt;/strong&gt; for your GUI application&lt;/li&gt;
&lt;li&gt;How to lay out widgets in &lt;strong&gt;main window–based&lt;/strong&gt; and &lt;strong&gt;dialog-based&lt;/strong&gt; applications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this knowledge and skillset, you’ll be able to use Python and PyQt to create professional-looking GUI applications.&lt;/p&gt;
&lt;p&gt;For a better understanding of how to use layout managers, some previous knowledge of how to create &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/&quot;&gt;PyQt GUI applications&lt;/a&gt; and how to work with &lt;a href=&quot;https://doc.qt.io/qt-5/qwidget.html&quot;&gt;PyQt widgets&lt;/a&gt; would be helpful.&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;laying-out-graphical-elements-on-a-gui&quot;&gt;Laying Out Graphical Elements on a GUI&lt;a class=&quot;headerlink&quot; href=&quot;#laying-out-graphical-elements-on-a-gui&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you’re creating &lt;a href=&quot;https://en.wikipedia.org/wiki/Graphical_user_interface&quot;&gt;graphical user interface (GUI)&lt;/a&gt; applications, a common issue is how to get your graphical components—&lt;a href=&quot;https://en.wikipedia.org/wiki/Button_(computing)&quot;&gt;buttons&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-menus-toolbars/&quot;&gt;menus, toolbars&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Label_(control)&quot;&gt;labels&lt;/a&gt;, and so on—laid out coherently on your forms and &lt;a href=&quot;https://en.wikipedia.org/wiki/Window_(computing)&quot;&gt;windows&lt;/a&gt;. This process is known as &lt;strong&gt;GUI layout&lt;/strong&gt;, and it’s an important step in creating GUI applications.&lt;/p&gt;
&lt;p&gt;In the past, if you wanted to lay out graphical components, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_widget&quot;&gt;widgets&lt;/a&gt;, on a window, then you would follow one of the following approaches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Decide on and manually set a static size and position for each widget on the window.&lt;/li&gt;
&lt;li&gt;Calculate and set the size and position of each widget dynamically.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first approach is fairly direct, but it has at least the following drawbacks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Your windows will be &lt;strong&gt;non-resizable&lt;/strong&gt;, which might cause problems when displaying them on different screen resolutions.&lt;/li&gt;
&lt;li&gt;Your labels might not support &lt;strong&gt;localization&lt;/strong&gt; properly because the length of a given text changes between languages.&lt;/li&gt;
&lt;li&gt;Your widgets will display differently on different platforms, which makes it difficult to write &lt;strong&gt;multiplatform&lt;/strong&gt; applications that look good.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The second approach is more flexible. However, it also has drawbacks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You have to do a lot of manual calculations to determine the right &lt;strong&gt;size&lt;/strong&gt; and &lt;strong&gt;position&lt;/strong&gt; of each widget.&lt;/li&gt;
&lt;li&gt;You have to do some extra calculations to respond correctly to &lt;strong&gt;window resizing&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You have to redo all the calculations any time you &lt;strong&gt;modify the layout&lt;/strong&gt; of your window.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Even though you can still use either of these two approaches to lay out your GUIs, most of the time you’ll want to use a third and more convenient approach implemented by most modern &lt;a href=&quot;https://en.wikipedia.org/wiki/Widget_toolkit&quot;&gt;GUI frameworks or toolkits&lt;/a&gt;: layout managers.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In some GUI frameworks, such as &lt;a href=&quot;https://realpython.com/python-gui-tkinter/&quot;&gt;Tkinter&lt;/a&gt;, layout managers are also referred to as &lt;strong&gt;geometry managers&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Layout_manager&quot;&gt;Layout managers&lt;/a&gt; automatically arrange widgets on a GUI according to your specific needs. They avoid the compatibility drawbacks of the first approach as well as the annoying and complicated calculations of the second approach.&lt;/p&gt;
&lt;p&gt;In the following sections, you’ll learn about PyQt’s built-in layout managers and how to use them to effectively lay out the graphical components of your GUI applications.&lt;/p&gt;
&lt;h2 id=&quot;getting-stocked-with-a-gallery-of-pyqt-layouts&quot;&gt;Getting Stocked With a Gallery of PyQt Layouts&lt;a class=&quot;headerlink&quot; href=&quot;#getting-stocked-with-a-gallery-of-pyqt-layouts&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In PyQt, widgets are graphical components that you use as building blocks for your GUI applications. When you place a bunch of widgets on a window to create a GUI, you need to give them some order. You need to set the widgets’ size and position on the window, and you also need to define their behavior for when the user resizes the underlying window.&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; Unfortunately, PyQt5’s &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/index.html&quot;&gt;official documentation&lt;/a&gt; has some incomplete sections. To work around this, you can check out the &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt4/&quot;&gt;PyQt4 documentation&lt;/a&gt;, the &lt;a href=&quot;https://doc.qt.io/qtforpython/&quot;&gt;Qt for Python documentation&lt;/a&gt;, or the original &lt;a href=&quot;https://doc.qt.io/&quot;&gt;Qt documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll find that most links will take you to the original Qt documentation, which is a better source of information in most cases.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;To arrange the widgets on windows or forms in PyQt, you can use the following techniques:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;.resize()&lt;/code&gt; and &lt;code&gt;.move()&lt;/code&gt; on your widgets to provide an absolute size and position.&lt;/li&gt;
&lt;li&gt;Reimplement &lt;code&gt;.resizeEvent()&lt;/code&gt; and calculate your widgets’ size and position dynamically.&lt;/li&gt;
&lt;li&gt;Use layout managers and let them do all the calculations and hard work for you.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These techniques generally correspond to the three different approaches for laying out a GUI that you saw in the previous section.&lt;/p&gt;
&lt;p&gt;Again, calculating the size and position dynamically might be a good approach, but most of the time you’ll be better off using &lt;a href=&quot;https://doc.qt.io/qt-5/layout.html&quot;&gt;layout managers&lt;/a&gt;. In PyQt, layout managers are classes that provide the required functionality to automatically manage the size, position, and resizing behavior of the widgets in the layout.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-pyqt-layout/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-pyqt-layout/ »&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>Formatting Python Strings</title>
      <id>https://realpython.com/courses/formatting-python-strings/</id>
      <link href="https://realpython.com/courses/formatting-python-strings/"/>
      <updated>2020-11-24T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll see two items to add to your Python string formatting toolkit. You&#x27;ll learn about Python&#x27;s string format method and the formatted string literal, or f-string. You&#x27;ll learn about these formatting techniques in detail and add them to your Python string formatting toolkit.</summary>
      <content type="html">
        &lt;p&gt;In this course, you&amp;rsquo;ll see two items to add to your Python string formatting toolkit. You&amp;rsquo;ll learn about Python&amp;rsquo;s string format method and the formatted string literal, or f-string. You&amp;rsquo;ll learn about these formatting techniques in detail and add them to your Python string formatting toolkit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;string &lt;code&gt;.format()&lt;/code&gt; method&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;formatted string literal&lt;/strong&gt;, or &lt;strong&gt;f-string&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&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>Split Your Dataset With scikit-learn&#x27;s train_test_split()</title>
      <id>https://realpython.com/train-test-split-python-data/</id>
      <link href="https://realpython.com/train-test-split-python-data/"/>
      <updated>2020-11-23T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn why it&#x27;s important to split your dataset in supervised machine learning and how to do that with train_test_split() from scikit-learn.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;One of the key aspects of supervised &lt;a href=&quot;https://realpython.com/learning-paths/machine-learning-python/&quot;&gt;machine learning&lt;/a&gt; is model evaluation and validation. When you evaluate the predictive performance of your model, it’s essential that the process be unbiased. Using &lt;a href=&quot;https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html&quot;&gt;&lt;strong&gt;&lt;code&gt;train_test_split()&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; from the data science library &lt;a href=&quot;https://scikit-learn.org/stable/index.html&quot;&gt;scikit-learn&lt;/a&gt;, you can split your dataset into subsets that minimize the potential for bias in your evaluation and validation process.&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;Why you need to &lt;strong&gt;split your dataset&lt;/strong&gt; in supervised machine learning&lt;/li&gt;
&lt;li&gt;Which &lt;strong&gt;subsets&lt;/strong&gt; of the dataset you need for an unbiased evaluation of your model&lt;/li&gt;
&lt;li&gt;How to use &lt;strong&gt;&lt;code&gt;train_test_split()&lt;/code&gt;&lt;/strong&gt; to split your data&lt;/li&gt;
&lt;li&gt;How to combine &lt;code&gt;train_test_split()&lt;/code&gt; with &lt;strong&gt;prediction methods&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, you’ll get information on related tools from &lt;a href=&quot;https://scikit-learn.org/stable/modules/classes.html#module-sklearn.model_selection&quot;&gt;&lt;code&gt;sklearn.model_selection&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&gt;Free Bonus:&lt;/strong&gt; &lt;a href=&quot;#&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-numpy-learning-guide&quot; data-focus=&quot;false&quot;&gt;Click here to get access to a free NumPy Resources Guide&lt;/a&gt; that points you to the best tutorials, videos, and books for improving your NumPy skills.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;the-importance-of-data-splitting&quot;&gt;The Importance of Data Splitting&lt;a class=&quot;headerlink&quot; href=&quot;#the-importance-of-data-splitting&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Supervised_learning&quot;&gt;Supervised machine learning&lt;/a&gt; is about creating models that precisely map the given inputs (independent variables, or &lt;strong&gt;predictors&lt;/strong&gt;) to the given outputs (dependent variables, or &lt;strong&gt;responses&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;How you measure the precision of your model depends on the type of a problem you’re trying to solve. In &lt;a href=&quot;https://realpython.com/linear-regression-in-python/#regression&quot;&gt;regression analysis&lt;/a&gt;, you typically use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Coefficient_of_determination&quot;&gt;coefficient of determination&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Root-mean-square_deviation&quot;&gt;root-mean-square error&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Mean_absolute_error&quot;&gt;mean absolute error&lt;/a&gt;, or similar quantities. For &lt;a href=&quot;https://realpython.com/logistic-regression-python/#classification&quot;&gt;classification&lt;/a&gt; problems, you often apply &lt;a href=&quot;https://developers.google.com/machine-learning/crash-course/classification/accuracy&quot;&gt;accuracy&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Precision_and_recall&quot;&gt;precision, recall&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/F1_score&quot;&gt;F1 score&lt;/a&gt;, and related indicators.&lt;/p&gt;
&lt;p&gt;The acceptable numeric values that measure precision vary from field to field. You can find detailed explanations from &lt;a href=&quot;https://statisticsbyjim.com/regression/how-high-r-squared/&quot;&gt;Statistics By Jim&lt;/a&gt;, &lt;a href=&quot;https://www.quora.com/How-do-I-decide-whether-a-certain-R-square-value-is-good-enough-in-regression-analysis&quot;&gt;Quora&lt;/a&gt;, and many other resources.&lt;/p&gt;
&lt;p&gt;What’s most important to understand is that you usually need &lt;strong&gt;unbiased evaluation&lt;/strong&gt; to properly use these measures, assess the predictive performance of your model, and validate the model.&lt;/p&gt;
&lt;p&gt;This means that you can’t evaluate the predictive performance of a model with the same data you used for training. You need evaluate the model with &lt;strong&gt;fresh data&lt;/strong&gt; that hasn’t been seen by the model before. You can accomplish that by splitting your dataset before you use it.&lt;/p&gt;
&lt;h3 id=&quot;training-validation-and-test-sets&quot;&gt;Training, Validation, and Test Sets&lt;a class=&quot;headerlink&quot; href=&quot;#training-validation-and-test-sets&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Splitting your dataset is essential for an unbiased evaluation of prediction performance. In most cases, it’s enough to split your dataset randomly into &lt;a href=&quot;https://en.wikipedia.org/wiki/Training,_validation,_and_test_sets&quot;&gt;three subsets&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt; The training set&lt;/strong&gt; is applied to train, or &lt;strong&gt;fit&lt;/strong&gt;, your model. For example, you use the training set to find the optimal weights, or coefficients, for &lt;a href=&quot;https://realpython.com/linear-regression-in-python/&quot;&gt;linear regression&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/logistic-regression-python/&quot;&gt;logistic regression&lt;/a&gt;, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_neural_network&quot;&gt;neural networks&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The validation set&lt;/strong&gt; is used for unbiased model evaluation during &lt;a href=&quot;https://en.wikipedia.org/wiki/Hyperparameter_optimization&quot;&gt;hyperparameter tuning&lt;/a&gt;. For example, when you want to find the optimal number of neurons in a neural network or the best kernel for a support vector machine, you experiment with different values. For each considered setting of hyperparameters, you fit the model with the training set and assess its performance with the validation set.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The test set&lt;/strong&gt; is needed for an unbiased evaluation of the final model. You shouldn’t use it for fitting or validation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In less complex cases, when you don’t have to tune hyperparameters, it’s okay to work with only the training and test sets.&lt;/p&gt;
&lt;h3 id=&quot;underfitting-and-overfitting&quot;&gt;Underfitting and Overfitting&lt;a class=&quot;headerlink&quot; href=&quot;#underfitting-and-overfitting&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Splitting a dataset might also be important for detecting if your model suffers from one of two very common problems, called &lt;a href=&quot;https://en.wikipedia.org/wiki/Overfitting&quot;&gt;underfitting and overfitting&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Underfitting&lt;/strong&gt; is usually the consequence of a model being unable to encapsulate the relations among data. For example, this can happen when trying to represent nonlinear relations with a linear model. Underfitted models will likely have poor performance with both training and test sets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Overfitting&lt;/strong&gt; usually takes place when a model has an excessively complex structure and learns both the existing relations among data and noise. Such models often have bad generalization capabilities. Although they work well with training data, they usually yield poor performance with unseen (test) data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can find a more detailed explanation of underfitting and overfitting in &lt;a href=&quot;https://realpython.com/linear-regression-in-python/#underfitting-and-overfitting&quot;&gt;Linear Regression in Python&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites-for-using-train_test_split&quot;&gt;Prerequisites for Using &lt;code&gt;train_test_split()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#prerequisites-for-using-train_test_split&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that you understand the need to split a dataset in order to perform unbiased model evaluation and identify underfitting or overfitting, you’re ready to learn how to split your own datasets.&lt;/p&gt;
&lt;p&gt;You’ll use version 0.23.1 of &lt;strong&gt;scikit-learn&lt;/strong&gt;, or &lt;strong&gt;&lt;code&gt;sklearn&lt;/code&gt;&lt;/strong&gt;. It has many packages for data science and machine learning, but for this tutorial you’ll focus on the  &lt;strong&gt;&lt;code&gt;model_selection&lt;/code&gt;&lt;/strong&gt;  package, specifically on the function &lt;strong&gt;&lt;code&gt;train_test_split()&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;You can &lt;a href=&quot;https://scikit-learn.org/stable/install.html&quot;&gt;install &lt;code&gt;sklearn&lt;/code&gt;&lt;/a&gt; with &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip install&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 -U &lt;span class=&quot;s2&quot;&gt;&quot;scikit-learn==0.23.1&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you use &lt;a href=&quot;https://www.anaconda.com/&quot;&gt;Anaconda&lt;/a&gt;, then you probably already have it installed. However, if you want to use a &lt;a href=&quot;https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html&quot;&gt;fresh environment&lt;/a&gt;, ensure that you have the specified version, or use &lt;a href=&quot;https://docs.conda.io/en/latest/miniconda.html&quot;&gt;Miniconda&lt;/a&gt;, then you can install &lt;code&gt;sklearn&lt;/code&gt; from Anaconda Cloud with &lt;code&gt;conda install&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/train-test-split-python-data/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/train-test-split-python-data/ »&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 #36: Sentiment Analysis, Fourier Transforms, and More Python Data Science</title>
      <id>https://realpython.com/podcasts/rpp/36/</id>
      <link href="https://realpython.com/podcasts/rpp/36/"/>
      <updated>2020-11-20T12:00:00+00:00</updated>
      <summary>Are you interested in learning more about Natural Language Processing? Have you heard of sentiment analysis? This week on the show, Kyle Stratis returns to talk about his new article titled, Use Sentiment Analysis With Python to Classify Movie Reviews. David Amos is also here, and all of us cover another batch of PyCoder’s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in learning more about Natural Language Processing? Have you heard of sentiment analysis? This week on the show, Kyle Stratis returns to talk about his new article titled, Use Sentiment Analysis With Python to Classify Movie Reviews. David Amos is also here, and all of us cover another batch of PyCoder’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 enumerate(): Simplify Looping With Counters</title>
      <id>https://realpython.com/python-enumerate/</id>
      <link href="https://realpython.com/python-enumerate/"/>
      <updated>2020-11-18T14: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 tutorial, 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;div&gt;&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 you don’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’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 tutorial, you’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;Use &lt;code&gt;enumerate()&lt;/code&gt; with &lt;strong&gt;conditional statements&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;p&gt;Let’s get started!&lt;/p&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free Download:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/cpython-internals-sample/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-cpython-internals-sample&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Get a sample chapter from CPython Internals: Your Guide to the Python 3 Interpreter&lt;/a&gt; showing you how to unlock the inner workings of the Python language, compile the Python interpreter from source  code, and participate in the development of CPython.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;iterating-with-for-loops-in-python&quot;&gt;Iterating With &lt;code&gt;for&lt;/code&gt; Loops in Python&lt;a class=&quot;headerlink&quot; href=&quot;#iterating-with-for-loops-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;for&lt;/code&gt; loop in Python uses &lt;strong&gt;collection-based iteration&lt;/strong&gt;. This means that Python assigns the next item from an iterable to the loop variable on every iteration, like in this example:&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;values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;a&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;b&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, &lt;code&gt;values&lt;/code&gt; is a &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list&lt;/a&gt; with three strings, &lt;code&gt;&quot;a&quot;&lt;/code&gt;, &lt;code&gt;&quot;b&quot;&lt;/code&gt;, and &lt;code&gt;&quot;c&quot;&lt;/code&gt;. In Python, lists are one type of iterable object. In the &lt;code&gt;for&lt;/code&gt; loop, the loop variable is &lt;code&gt;value&lt;/code&gt;. On each iteration of the loop, &lt;code&gt;value&lt;/code&gt; is set to the next item from &lt;code&gt;values&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Next, you &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;print&lt;/a&gt; &lt;code&gt;value&lt;/code&gt; onto the screen. The advantage of collection-based iteration is that it helps avoid the &lt;a href=&quot;https://en.wikipedia.org/wiki/Off-by-one_error&quot;&gt;off-by-one error&lt;/a&gt; that is common in other programming languages.&lt;/p&gt;
&lt;p&gt;Now imagine that, in addition to the value itself, you want to print the index of the item in the list to the screen on every iteration. One way to approach this task is to create a variable to store the index and update it on each iteration:&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;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&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;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0 a&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1 b&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2 c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, &lt;code&gt;index&lt;/code&gt; is an integer that keeps track of how far into the list you are. On each iteration of the loop, you print &lt;code&gt;index&lt;/code&gt; as well as &lt;code&gt;value&lt;/code&gt;. The last step in the loop is to update the number stored in &lt;code&gt;index&lt;/code&gt; by one. A common bug occurs when you forget to update &lt;code&gt;index&lt;/code&gt; on each iteration:&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;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0 a&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0 b&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0 c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, &lt;code&gt;index&lt;/code&gt; stays at &lt;code&gt;0&lt;/code&gt; on every iteration because there’s no code to update its value at the end of the loop. Particularly for long or complicated loops, this kind of bug is notoriously hard to track down.&lt;/p&gt;
&lt;p&gt;Another common way to approach this problem is to use &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#range&quot;&gt;&lt;code&gt;range()&lt;/code&gt;&lt;/a&gt; combined with &lt;a href=&quot;https://docs.python.org/3/library/functions.html#len&quot;&gt;&lt;code&gt;len()&lt;/code&gt;&lt;/a&gt; to create an index automatically. This way, you don’t need to remember to update the index:&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;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&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;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0 a&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1 b&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2 c&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, &lt;code&gt;len(values)&lt;/code&gt; returns the length of &lt;code&gt;values&lt;/code&gt;, which is &lt;code&gt;3&lt;/code&gt;. Then &lt;a href=&quot;https://realpython.com/python-range/&quot;&gt;&lt;code&gt;range()&lt;/code&gt;&lt;/a&gt; creates an iterator running from the default starting value of &lt;code&gt;0&lt;/code&gt; until it reaches &lt;code&gt;len(values)&lt;/code&gt; minus one. In this case, &lt;code&gt;index&lt;/code&gt; becomes your loop variable. In the loop, you set &lt;code&gt;value&lt;/code&gt; equal to the item in &lt;code&gt;values&lt;/code&gt; at the current value of &lt;code&gt;index&lt;/code&gt;. Finally, you print &lt;code&gt;index&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With this example, one common bug that can occur is when you forget to update &lt;code&gt;value&lt;/code&gt; at the beginning of each iteration. This is similar to the previous bug of forgetting to update the index. This is one reason that this loop isn’t considered  &lt;a href=&quot;https://realpython.com/courses/how-to-write-pythonic-loops/&quot;&gt;Pythonic&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This example is also somewhat restricted because &lt;code&gt;values&lt;/code&gt; has to allow access to its items using integer indices. Iterables that allow this kind of access are called &lt;strong&gt;sequences&lt;/strong&gt; in Python.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Technical Detail:&lt;/strong&gt; According to the &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-iterable&quot;&gt;Python documentation&lt;/a&gt;, an &lt;strong&gt;iterable&lt;/strong&gt; is any object that can return its members one at a time. By definition, iterables support the &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#typeiter&quot;&gt;iterator protocol&lt;/a&gt;, which specifies how object members are returned when an object is used in an &lt;a href=&quot;https://docs.python.org/3/glossary.html#term-iterator&quot;&gt;iterator&lt;/a&gt;. Python has two commonly used types of iterables:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/glossary.html#term-sequence&quot;&gt;Sequences&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3/glossary.html#term-generator&quot;&gt;Generators&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Any iterable can be used in a &lt;code&gt;for&lt;/code&gt; loop, but only sequences can be accessed by &lt;a href=&quot;https://realpython.com/python-numbers/#integers&quot;&gt;integer&lt;/a&gt; indices. Trying to access items by index from a &lt;a href=&quot;http://www.dabeaz.com/generators/Generators.pdf&quot;&gt;generator&lt;/a&gt; or an &lt;a href=&quot;https://dbader.org/blog/python-iterators&quot;&gt;iterator&lt;/a&gt; will raise a &lt;code&gt;TypeError&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;enum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&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;enum&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;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;TypeError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;&#x27;enumerate&#x27; object is not subscriptable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you assign the return value of &lt;code&gt;enumerate()&lt;/code&gt; to &lt;code&gt;enum&lt;/code&gt;. &lt;code&gt;enumerate()&lt;/code&gt; is an iterator, so attempting to access its values by index raises a &lt;code&gt;TypeError&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Fortunately, Python’s &lt;a href=&quot;https://docs.python.org/3/library/functions.html#enumerate&quot;&gt;&lt;code&gt;enumerate()&lt;/code&gt;&lt;/a&gt; lets you avoid all these problems. It’s a &lt;strong&gt;built-in&lt;/strong&gt; function, which means that it’s been available in every version of Python since it was &lt;a href=&quot;https://www.python.org/dev/peps/pep-0279/&quot;&gt;added in Python 2.3&lt;/a&gt;, way back in 2003.&lt;/p&gt;
&lt;h2 id=&quot;using-pythons-enumerate&quot;&gt;Using Python’s &lt;code&gt;enumerate()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#using-pythons-enumerate&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can use &lt;a href=&quot;https://realpython.com/courses/how-to-write-pythonic-loops/&quot;&gt;&lt;code&gt;enumerate()&lt;/code&gt;&lt;/a&gt; in a loop in almost the same way that you use the original iterable object. Instead of putting the iterable directly after &lt;code&gt;in&lt;/code&gt; in the &lt;code&gt;for&lt;/code&gt; loop, you put it inside the parentheses of &lt;code&gt;enumerate()&lt;/code&gt;. You also have to change the loop variable a little bit, as shown in this example:&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;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0 a&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1 b&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2 c&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/python-enumerate/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-enumerate/ »&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>Regular Expressions and Building Regexes in Python</title>
      <id>https://realpython.com/courses/building-regexes-python/</id>
      <link href="https://realpython.com/courses/building-regexes-python/"/>
      <updated>2020-11-17T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn how to perform more complex string pattern matching using regular expressions, or regexes, in Python. You&#x27;ll also explore more advanced regex tools and techniques that are available in Python.</summary>
      <content type="html">
        &lt;p&gt;In this course, you&amp;rsquo;ll explore &lt;strong&gt;regular expressions&lt;/strong&gt;, also known as &lt;strong&gt;regexes&lt;/strong&gt;, in Python. A regex is a special sequence of characters that defines a pattern for complex string-matching functionality.&lt;/p&gt;
&lt;p&gt;String matching like this is a common task in programming, and you can get a lot done with string operators and built-in methods. At times, though, you may need more sophisticated pattern-matching capabilities.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to access the &lt;strong&gt;&lt;code&gt;re&lt;/code&gt; module&lt;/strong&gt;, which implements regex matching in Python&lt;/li&gt;
&lt;li&gt;How to use &lt;strong&gt;&lt;code&gt;re.search()&lt;/code&gt;&lt;/strong&gt; to match a pattern against a string&lt;/li&gt;
&lt;li&gt;How to create complex matching pattern with regex &lt;strong&gt;metacharacters&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Explore more functions, beyond &lt;code&gt;re.search()&lt;/code&gt;, that the &lt;code&gt;re&lt;/code&gt; module provides&lt;/li&gt;
&lt;li&gt;Learn when and how to precompile a regex in Python into a &lt;strong&gt;regular expression object&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Discover useful things that you can do with the &lt;strong&gt;match object&lt;/strong&gt; returned by the functions in the &lt;code&gt;re&lt;/code&gt; module&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 and PyQt: Creating Menus, Toolbars, and Status Bars</title>
      <id>https://realpython.com/python-menus-toolbars/</id>
      <link href="https://realpython.com/python-menus-toolbars/"/>
      <updated>2020-11-16T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you’ll learn how to create, customize, and use Python menus, toolbars, and status bars for creating GUI applications using PyQt.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;When it comes to developing &lt;a href=&quot;https://en.wikipedia.org/wiki/Graphical_user_interface&quot;&gt;graphical user interface (GUI)&lt;/a&gt; applications with Python and &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/&quot;&gt;PyQt&lt;/a&gt;, some of the most useful and versatile graphical elements that you’ll ever use are &lt;a href=&quot;https://en.wikipedia.org/wiki/Menu_(computing)&quot;&gt;menus&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Toolbar&quot;&gt;toolbars&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Status_bar&quot;&gt;status bars&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Menus and toolbars can make your applications look &lt;strong&gt;polished&lt;/strong&gt; and &lt;strong&gt;professional&lt;/strong&gt;, presenting users with an accessible set of options, while status bars allow you to display relevant information about the application’s status.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;menus&lt;/strong&gt;, &lt;strong&gt;toolbars&lt;/strong&gt;, and &lt;strong&gt;status bars&lt;/strong&gt; are&lt;/li&gt;
&lt;li&gt;How to create menus, toolbars, and status bars &lt;strong&gt;programmatically&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to populate Python menu and toolbar using &lt;strong&gt;PyQt actions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to use status bars to display &lt;strong&gt;status information&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, you’ll learn some &lt;strong&gt;programming best practices&lt;/strong&gt; that you can apply when creating menus, toolbars, and status bars with Python and PyQt. If you’re new to GUI programming with PyQt, then you can check out &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/&quot;&gt;Python and PyQt: Building a GUI Desktop Calculator&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can download the code and resources for the sample application that you’ll build in this tutorial by clicking on the box 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;Download the sample code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-pyqt-menus/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-pyqt-menus&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get the code you’ll use&lt;/a&gt; to learn how to add menus, toolbars, and status bars to your GUI applications using Python and PyQt.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;building-python-menu-bars-menus-and-toolbars-in-pyqt&quot;&gt;Building Python Menu Bars, Menus, and Toolbars in PyQt&lt;a class=&quot;headerlink&quot; href=&quot;#building-python-menu-bars-menus-and-toolbars-in-pyqt&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;menu bar&lt;/strong&gt; is a region of a GUI application’s &lt;a href=&quot;https://realpython.com/python-pyqt-layout/&quot;&gt;main window&lt;/a&gt; that holds &lt;strong&gt;menus&lt;/strong&gt;. Menus are pull-down lists of options that provide convenient access to your application’s options. For example, if you were creating a text editor, then you might have some of the following menus in your menu bar:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;File&lt;/em&gt; menu that provides some of the following menu options:&lt;ul&gt;
&lt;li&gt;&lt;em&gt;New&lt;/em&gt; for creating a new document&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Open&lt;/em&gt; for opening an existing document&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Open Recent&lt;/em&gt; for opening recent documents&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Save&lt;/em&gt; for saving a document&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Exit&lt;/em&gt; for exiting the application&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;An &lt;em&gt;Edit&lt;/em&gt; menu that provides some of the following menu options:&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Copy&lt;/em&gt; for copying some text&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Paste&lt;/em&gt; for pasting some text&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Cut&lt;/em&gt; for cutting some text&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;em&gt;Help&lt;/em&gt; menu that provides some of the following menu options:&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Help Content&lt;/em&gt; for launching to user’s manual and help content&lt;/li&gt;
&lt;li&gt;&lt;em&gt;About&lt;/em&gt; for launching an About dialog&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also add some of these options to a &lt;strong&gt;toolbar&lt;/strong&gt;. A toolbar is a panel of buttons with meaningful icons that provide fast access to the most commonly used options in an application. In your text editor example, you could add options like &lt;em&gt;New&lt;/em&gt;, &lt;em&gt;Open&lt;/em&gt;, &lt;em&gt;Save&lt;/em&gt;, &lt;em&gt;Copy&lt;/em&gt;, and &lt;em&gt;Paste&lt;/em&gt; to a toolbar.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In this tutorial, you’ll develop a sample application that implements all the above menus and options. You can use this sample application as a starting point to create a text editor project.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In this section, you’ll learn the basics of how to add menu bars, menus, and toolbars to your GUI applications with Python and PyQt.&lt;/p&gt;
&lt;p&gt;Before going any further, you’ll create a sample PyQt application that you’ll use throughout this tutorial. In each section, you’ll add new features and functionalities to this sample application. The application will be a &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/#main-windows&quot;&gt;main window–style application&lt;/a&gt;. This means that it’ll have a menu bar, a toolbar, a status bar, and a central widget.&lt;/p&gt;
&lt;p&gt;Open your favorite &lt;a href=&quot;https://realpython.com/python-ides-code-editors-guide/&quot;&gt;code editor or IDE&lt;/a&gt; and create a Python file called &lt;code&gt;sample_app.py&lt;/code&gt;. Then add the following code to it:&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;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sys&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;PyQt5.QtCore&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Qt&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;PyQt5.QtWidgets&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QLabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QMainWindow&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;QMainWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Main Window.&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fm&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;sd&quot;&gt;&quot;&quot;&quot;Initializer.&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;super&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;fm&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setWindowTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Python Menus &amp;amp; Toolbars&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;centralWidget&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QLabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello, World&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;centralWidget&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setAlignment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Qt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AlignHCenter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Qt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AlignVCenter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setCentralWidget&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;centralWidget&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vm&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;win&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;win&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exec_&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;Now &lt;code&gt;sample_app.py&lt;/code&gt; contains all the code that you need for creating your sample PyQt application. In this case, &lt;code&gt;Window&lt;/code&gt; inherits from &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qmainwindow.html&quot;&gt;&lt;code&gt;QMainWindow&lt;/code&gt;&lt;/a&gt;. So, you’re building a main window–style application.&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; Unfortunately, PyQt5’s &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/index.html&quot;&gt;official documentation&lt;/a&gt; has some incomplete sections. To work around this, you can check out either the &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt4/&quot;&gt;PyQt4 documentation&lt;/a&gt; or the original &lt;a href=&quot;https://doc.qt.io/&quot;&gt;Qt documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In the class initializer &lt;code&gt;.__init__()&lt;/code&gt;, you first call the parent class’s initializer using &lt;a href=&quot;https://realpython.com/python-super/&quot;&gt;&lt;code&gt;super()&lt;/code&gt;&lt;/a&gt;. Then you set the title of the window using &lt;code&gt;.setWindowTitle()&lt;/code&gt; and resize the window using &lt;code&gt;.resize()&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you aren’t familiar with PyQt applications and how to create them, then you can check out &lt;a href=&quot;https://realpython.com/python-pyqt-gui-calculator/&quot;&gt;Python and PyQt: Building a GUI Desktop Calculator&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The window’s central widget is a &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qlabel.html&quot;&gt;&lt;code&gt;QLabel&lt;/code&gt;&lt;/a&gt; object that you’ll use to show messages in response to certain user actions. These messages will display at the center of the window. To do this, you call &lt;code&gt;.setAlignment()&lt;/code&gt; on the &lt;code&gt;QLabel&lt;/code&gt; object with a couple of &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtcore/qt.html#AlignmentFlag&quot;&gt;alignment flags&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run the application from your command line&lt;/a&gt;, then you’ll see the following window on your screen:&lt;/p&gt;
&lt;figure&gt;&lt;a href=&quot;https://files.realpython.com/media/pyqt-sample-app.1926ae5ad791.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block &quot; src=&quot;https://files.realpython.com/media/pyqt-sample-app.1926ae5ad791.png&quot; width=&quot;430&quot; height=&quot;247&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pyqt-sample-app.1926ae5ad791.png&amp;amp;w=107&amp;amp;sig=ff9a3db0109bd7bc7783f35dce58e2861b277004 107w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pyqt-sample-app.1926ae5ad791.png&amp;amp;w=215&amp;amp;sig=43af069702f64803ff034a09003dd8a2cbb50632 215w, https://files.realpython.com/media/pyqt-sample-app.1926ae5ad791.png 430w&quot; sizes=&quot;75vw&quot; alt=&quot;PyQt Sample Application&quot; data-asset=&quot;2985&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;That’s it! You’ve created a main window–style application with Python and PyQt. You’ll use this sample application for all the upcoming examples in this tutorial.&lt;/p&gt;
&lt;h3 id=&quot;creating-menu-bars&quot;&gt;Creating Menu Bars&lt;a class=&quot;headerlink&quot; href=&quot;#creating-menu-bars&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-menus-toolbars/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-menus-toolbars/ »&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 #35: Security and Authorization in Your Python Web Applications</title>
      <id>https://realpython.com/podcasts/rpp/35/</id>
      <link href="https://realpython.com/podcasts/rpp/35/"/>
      <updated>2020-11-13T12:00:00+00:00</updated>
      <summary>So you built a web application in Python. Now how are you going to authorize users? Security goes beyond authentication. Who gets to do what, where, and when? This week on the show, we have Sam Scott, chief technology officer from Oso. Oso is an open-source policy engine for authorization that you embed in your application.</summary>
      <content type="html">
        &lt;p&gt;So you built a web application in Python. Now how are you going to authorize users? Security goes beyond authentication. Who gets to do what, where, and when? This week on the show, we have Sam Scott, chief technology officer from Oso. Oso is an open-source policy engine for authorization that you embed in your application.&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>PyPy: Faster Python With Minimal Effort</title>
      <id>https://realpython.com/pypy-faster-python/</id>
      <link href="https://realpython.com/pypy-faster-python/"/>
      <updated>2020-11-11T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how you can use PyPy to improve the speed of your applications. You&#x27;ll see how PyPy compares with other Python implementations like CPython and learn about features that you can use to gain significant performance boosts without making changes to your code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Python is one of the most popular programming languages among developers, but it has certain limitations. For example, depending on the application, it can be up to &lt;a href=&quot;https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/python3-gcc.html&quot;&gt;100 times as slow&lt;/a&gt; as some lower-level languages. That’s why many companies rewrite their applications in another language once Python’s speed becomes a bottleneck for users. But what if there was a way to keep Python’s awesome features and improve its speed? Enter &lt;a href=&quot;https://doc.pypy.org/en/latest/introduction.html&quot;&gt;PyPy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PyPy&lt;/strong&gt; is a very compliant Python interpreter that is a worthy alternative to CPython 2.7, 3.6, and soon 3.7. By installing and running your application with it, you can gain noticeable speed improvements. How much of an improvement you’ll see depends on the application you’re running.&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 to install and run your code with &lt;strong&gt;PyPy&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How PyPy compares with &lt;strong&gt;CPython&lt;/strong&gt; in terms of speed&lt;/li&gt;
&lt;li&gt;What PyPy’s &lt;strong&gt;features&lt;/strong&gt; are and how they make your Python code run &lt;strong&gt;faster&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;What PyPy’s &lt;strong&gt;limitations&lt;/strong&gt; are&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The examples in this tutorial use Python 3.6 since that’s the latest version of Python that PyPy is compatible with.&lt;/p&gt;
&lt;h2 id=&quot;python-and-pypy&quot;&gt;Python and PyPy&lt;a class=&quot;headerlink&quot; href=&quot;#python-and-pypy&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Python &lt;a href=&quot;https://docs.python.org/3/reference/index.html&quot;&gt;language specification&lt;/a&gt; is used in a number of implementations such as &lt;a href=&quot;https://realpython.com/cpython-source-code-guide/&quot;&gt;CPython&lt;/a&gt; (written in C), Jython (written in Java), IronPython (written for .NET), and PyPy (written in Python).&lt;/p&gt;
&lt;p&gt;CPython is the original implementation of Python and is by far the most popular and most maintained. When people refer to Python, they more often than not mean CPython. You’re probably using CPython right now!&lt;/p&gt;
&lt;p&gt;However, because it’s a high-level interpreted language, CPython has certain limitations and won’t win any medals for speed. That’s where PyPy can come in handy. Since it adheres to the Python language specification, PyPy requires no change in your codebase and can offer significant speed improvements thanks to the features you’ll see below.&lt;/p&gt;
&lt;p&gt;Now, you may be wondering why CPython doesn’t implement PyPy’s awesome features if they use the same syntax. The reason is that implementing those features would require huge changes to the source code and would be a major undertaking.&lt;/p&gt;
&lt;p&gt;Without diving too much into theory, let’s see PyPy in action.&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;Your OS may already provide a PyPy package. On macOS, for example, you can install it with the help of &lt;a href=&quot;https://brew.sh/&quot;&gt;Homebrew&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; brew install pypy3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If not, you can &lt;a href=&quot;https://www.pypy.org/download.html&quot;&gt;download a prebuilt binary for your OS and architecture&lt;/a&gt;. Once you complete the download, it’s just a matter of unpacking the tarball or ZIP file. Then you can execute PyPy without needing to install it anywhere:&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; tar xf pypy3.6-v7.3.1-osx64.tar.bz2
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; ./pypy3.6-v7.3.1-osx64/bin/pypy3
&lt;span class=&quot;go&quot;&gt;Python 3.6.9 (?, Jul 19 2020, 21:37:06)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[PyPy 7.3.1 with GCC 4.2.1]&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Before executing the code above, you need to be inside the folder where you downloaded the binary. Refer to the &lt;a href=&quot;https://doc.pypy.org/en/latest/install.html&quot;&gt;installation documentation&lt;/a&gt; for the complete instructions.&lt;/p&gt;
&lt;h3 id=&quot;pypy-in-action&quot;&gt;PyPy in Action&lt;a class=&quot;headerlink&quot; href=&quot;#pypy-in-action&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You now have PyPy installed and you’re ready to see it in action! To do that, create a Python file called &lt;code&gt;script.py&lt;/code&gt; and put the following code in it:&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;n&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The result is &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;total&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is a script that, in two nested &lt;a href=&quot;https://realpython.com/python-for-loop/&quot;&gt;&lt;code&gt;for&lt;/code&gt; loops&lt;/a&gt;, adds the numbers from &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;9,999&lt;/code&gt;, and &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;prints&lt;/a&gt; the result.&lt;/p&gt;
&lt;p&gt;To see how long it takes to run this script, edit it to add the highlighted lines:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/pypy-faster-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/pypy-faster-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Handling Missing Keys With the Python defaultdict Type</title>
      <id>https://realpython.com/courses/python-defaultdict-type/</id>
      <link href="https://realpython.com/courses/python-defaultdict-type/"/>
      <updated>2020-11-10T14:00:00+00:00</updated>
      <summary>In this step-by-step course, you&#x27;ll learn how the Python defaultdict type works and how to use it for handling missing keys when you&#x27;re working with dictionaries. You&#x27;ll also learn how to use a defaultdict to solve problems like grouping or counting the items in a sequence or collection.</summary>
      <content type="html">
        &lt;p&gt;The Python &lt;a href=&quot;https://docs.python.org/3/library/collections.html#collections.defaultdict&quot;&gt;&lt;code&gt;defaultdict&lt;/code&gt;&lt;/a&gt; type behaves almost exactly like a regular Python dictionary, but if you try to access or modify a missing key, then &lt;code&gt;defaultdict&lt;/code&gt; will automatically create the key and generate a default value for it. This makes &lt;code&gt;defaultdict&lt;/code&gt; a valuable option for handling missing keys in dictionaries.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to use the Python &lt;code&gt;defaultdict&lt;/code&gt; type for &lt;strong&gt;handling missing keys&lt;/strong&gt; in a dictionary&lt;/li&gt;
&lt;li&gt;When and why to use a Python &lt;code&gt;defaultdict&lt;/code&gt; rather than a regular &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;&lt;code&gt;dict&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;How to use a &lt;code&gt;defaultdict&lt;/code&gt; for &lt;strong&gt;grouping&lt;/strong&gt;, &lt;strong&gt;counting&lt;/strong&gt;, and &lt;strong&gt;accumulating&lt;/strong&gt; operations&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>Use Sentiment Analysis With Python to Classify Movie Reviews</title>
      <id>https://realpython.com/sentiment-analysis-python/</id>
      <link href="https://realpython.com/sentiment-analysis-python/"/>
      <updated>2020-11-09T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about sentiment analysis and how it works in Python. You&#x27;ll then build your own sentiment analysis classifier with spaCy that can predict whether a movie review is positive or negative.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;strong&gt;Sentiment analysis&lt;/strong&gt; is a powerful tool that allows computers to understand the underlying subjective tone of a piece of writing. This is something that humans have difficulty with, and as you might imagine, it isn’t always so easy for computers, either. But with the right tools and Python, you can use sentiment analysis to better understand the &lt;strong&gt;sentiment&lt;/strong&gt; of a piece of writing.&lt;/p&gt;
&lt;p&gt;Why would you want to do that? There are a lot of uses for sentiment analysis, such as understanding how stock traders feel about a particular company by using social media data or aggregating reviews, which you’ll get to do by the end of this tutorial. &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 to use &lt;strong&gt;natural language processing (NLP)&lt;/strong&gt; techniques&lt;/li&gt;
&lt;li&gt;How to use machine learning to &lt;strong&gt;determine the sentiment&lt;/strong&gt; of text&lt;/li&gt;
&lt;li&gt;How to use spaCy to &lt;strong&gt;build an NLP pipeline&lt;/strong&gt; that feeds into a sentiment analysis classifier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This tutorial is ideal for beginning machine learning practitioners who want a project-focused guide to building sentiment analysis pipelines with spaCy. &lt;/p&gt;
&lt;p&gt;You should be familiar with basic &lt;a href=&quot;https://realpython.com/tutorials/machine-learning&quot;&gt;machine learning techniques&lt;/a&gt; like binary classification as well as the concepts behind them, such as training loops, data batches, and weights and biases. If you’re unfamiliar with machine learning, then you can kickstart your journey by learning about &lt;a href=&quot;https://realpython.com/logistic-regression-python/&quot;&gt;logistic regression&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you’re ready, you can follow along with the examples in this tutorial by downloading the source code from 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;Get the Source Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/sentiment-analysis-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-sentiment-analysis-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 learn about sentiment analysis with natural language processing in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;using-natural-language-processing-to-preprocess-and-clean-text-data&quot;&gt;Using Natural Language Processing to Preprocess and Clean Text Data&lt;a class=&quot;headerlink&quot; href=&quot;#using-natural-language-processing-to-preprocess-and-clean-text-data&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Any sentiment analysis workflow begins with loading data. But what do you do once the data’s been loaded? You need to process it through a &lt;strong&gt;natural language processing pipeline&lt;/strong&gt; before you can do anything interesting with it.&lt;/p&gt;
&lt;p&gt;The necessary steps include (but aren’t limited to) the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Tokenizing sentences&lt;/strong&gt; to break text down into sentences, words, or other units &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Removing stop words&lt;/strong&gt; like “if,” “but,” “or,” and so on&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normalizing words&lt;/strong&gt; by condensing all forms of a word into a single form&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vectorizing text&lt;/strong&gt; by turning the text into a numerical representation for consumption by your classifier&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All these steps serve to reduce the &lt;strong&gt;noise&lt;/strong&gt; inherent in any human-readable text and improve the accuracy of your classifier’s results. There are lots of great tools to help with this, such as the &lt;a href=&quot;https://www.nltk.org/&quot;&gt;Natural Language Toolkit&lt;/a&gt;, &lt;a href=&quot;https://textblob.readthedocs.io/en/dev/index.html&quot;&gt;TextBlob&lt;/a&gt;, and &lt;a href=&quot;https://spacy.io/&quot;&gt;spaCy&lt;/a&gt;. For this tutorial, you’ll use spaCy.&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; spaCy is a very powerful tool with many features. For a deep dive into many of these features, check out &lt;a href=&quot;https://realpython.com/natural-language-processing-spacy-python/&quot;&gt;Natural Language Processing With spaCy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Before you go further, make sure you have spaCy and its English model installed:&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; pip install spacy
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; python -m spacy download en_core_web_sm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The first command installs spaCy, and the second uses spaCy to download its English language model. spaCy supports a number of different languages, which are listed on the &lt;a href=&quot;https://spacy.io/usage/models&quot;&gt;spaCy website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Next, you’ll learn how to use spaCy to help with the preprocessing steps you learned about earlier, starting with tokenization.&lt;/p&gt;
&lt;h3 id=&quot;tokenizing&quot;&gt;Tokenizing&lt;a class=&quot;headerlink&quot; href=&quot;#tokenizing&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Tokenization&lt;/strong&gt; is the process of breaking down chunks of text into smaller pieces. spaCy comes with a default processing pipeline that begins with tokenization, making this process a snap. In spaCy, you can do either sentence tokenization or word tokenization:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Word tokenization&lt;/strong&gt; breaks text down into individual words.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sentence tokenization&lt;/strong&gt; breaks text down into individual sentences.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, you’ll use word tokenization to separate the text into individual words. First, you’ll load the text into spaCy, which does the work of tokenization for you:&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;spacy&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;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Dave watched as the forest burned up on the hill,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;only a few miles from his house. The car had&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;been hastily packed and Marta was inside trying to round&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;up the last of the pets. &quot;Where could she be?&quot; he wondered&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;as he continued to wait for Marta to appear with the pets.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nlp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spacy&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;s2&quot;&gt;&quot;en_core_web_sm&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;doc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nlp&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;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;token_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;token&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;token&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doc&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;token_list&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;, Dave, watched, as, the, forest, burned, up, on, the, hill, ,,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;, only, a, few, miles, from, his, house, ., The, car, had,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;, been, hastily, packed, and, Marta, was, inside, trying, to, round,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;, up, the, last, of, the, pets, ., &quot;, Where, could, she, be, ?, &quot;, he, wondered,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;, as, he, continued, to, wait, for, Marta, to, appear, with, the, pets, .,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this code, you set up some example text to tokenize, load spaCy’s English model, and then tokenize the text by passing it into the &lt;code&gt;nlp&lt;/code&gt; constructor. This model includes a default processing pipeline that you can customize, as you’ll see later in the project section.&lt;/p&gt;
&lt;p&gt;After that, you generate a list of tokens and print it. As you may have noticed, “word tokenization” is a slightly misleading term, as captured tokens include punctuation and other nonword strings. &lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/sentiment-analysis-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/sentiment-analysis-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #34: The Python Modulo Operator &amp; Managing Data With SQLite and SQLAlchemy</title>
      <id>https://realpython.com/podcasts/rpp/34/</id>
      <link href="https://realpython.com/podcasts/rpp/34/"/>
      <updated>2020-11-06T12:00:00+00:00</updated>
      <summary>Are you ready to move beyond flat files for your data in Python? Maybe you&#x27;re not sure where to start with databases and SQL. This week on the show, David Amos returns with another batch of PyCoder’s Weekly articles and projects. We cover a Real Python article about managing data with SQLite and SQLAlchemy.</summary>
      <content type="html">
        &lt;p&gt;Are you ready to move beyond flat files for your data in Python? Maybe you&#x27;re not sure where to start with databases and SQL. This week on the show, David Amos returns with another batch of PyCoder’s Weekly articles and projects. We cover a Real Python article about managing data with SQLite and SQLAlchemy.&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>Caching in Python Using the LRU Cache Strategy</title>
      <id>https://realpython.com/lru-cache-python/</id>
      <link href="https://realpython.com/lru-cache-python/"/>
      <updated>2020-11-04T14:00:00+00:00</updated>
      <summary>Caching is an essential optimization technique. In this tutorial, you&#x27;ll learn how to use Python&#x27;s @lru_cache decorator to cache the results of your functions using the LRU cache strategy. This is a powerful technique you can use to leverage the power of caching in your implementations.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;There are many ways to achieve fast and responsive applications. &lt;strong&gt;Caching&lt;/strong&gt; is one approach that, when used correctly, makes things much faster while decreasing the load on computing resources. Python’s &lt;a href=&quot;https://docs.python.org/3/library/functools.html&quot;&gt;&lt;code&gt;functools&lt;/code&gt; module&lt;/a&gt; comes with the &lt;a href=&quot;https://docs.python.org/3/library/functools.html#functools.lru_cache&quot;&gt;&lt;code&gt;@lru_cache&lt;/code&gt; decorator&lt;/a&gt;, which gives you the ability to cache the result of your functions using the &lt;strong&gt;Least Recently Used (LRU) strategy&lt;/strong&gt;. This is a simple yet powerful technique that you can use to leverage the power of caching in your code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;caching strategies&lt;/strong&gt; are available and how to implement them using &lt;strong&gt;Python decorators&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;LRU strategy&lt;/strong&gt; is and how it works&lt;/li&gt;
&lt;li&gt;How to improve performance by caching with the &lt;strong&gt;&lt;code&gt;@lru_cache&lt;/code&gt; decorator&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to expand the functionality of the &lt;code&gt;@lru_cache&lt;/code&gt; decorator and make it &lt;strong&gt;expire&lt;/strong&gt; after a specific time&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the end of this tutorial, you’ll have a deeper understanding of how caching works and how to take advantage of it 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-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;caching-and-its-uses&quot;&gt;Caching and Its Uses&lt;a class=&quot;headerlink&quot; href=&quot;#caching-and-its-uses&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Caching&lt;/strong&gt; is an optimization technique that you can use in your applications to keep recent or often-used data in memory locations that are faster or computationally cheaper to access than their source. &lt;/p&gt;
&lt;p&gt;Imagine you’re building a newsreader application that fetches the latest news from different sources. As the user navigates through the list, your application downloads the articles and displays them on the screen.&lt;/p&gt;
&lt;p&gt;What would happen if the user decided to move repeatedly back and forth between a couple of news articles? Unless you were caching the data, your application would have to fetch the same content every time! That would make your user’s system sluggish and put extra pressure on the server hosting the articles.&lt;/p&gt;
&lt;p&gt;A better approach would be to store the content locally after fetching each article. Then, the next time the user decided to open an article, your application could open the content from a locally stored copy instead of going back to the source. In computer science, this technique is called &lt;strong&gt;caching&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;implementing-a-cache-using-a-python-dictionary&quot;&gt;Implementing a Cache Using a Python Dictionary&lt;a class=&quot;headerlink&quot; href=&quot;#implementing-a-cache-using-a-python-dictionary&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can implement a caching solution in Python using a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Staying with the newsreader example, instead of going directly to the server every time you need to download an article, you can check whether you have the content in your cache and go back to the server only if you don’t. You can use the article’s URL as the key and its content as the value.&lt;/p&gt;
&lt;p&gt;Here’s an example of how this caching technique might look:&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;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&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;n&quot;&gt;cache&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;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;get_article_from_server&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;linenos&quot;&gt; 6&lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Fetching article from server...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&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;k&quot;&gt;return&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;text&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_article&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;linenos&quot;&gt;11&lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Getting article...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;12&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;13&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;cache&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;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get_article_from_server&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;linenos&quot;&gt;14&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;15&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cache&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;linenos&quot;&gt;16&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;17&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;s2&quot;&gt;&quot;https://realpython.com/sorting-algorithms-python/&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_article&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://realpython.com/sorting-algorithms-python/&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;Save this code to a &lt;code&gt;caching.py&lt;/code&gt; file, &lt;a href=&quot;https://realpython.com/what-is-pip/#installing-packages-with-pip&quot;&gt;install&lt;/a&gt; the &lt;a href=&quot;https://realpython.com/python-requests/&quot;&gt;&lt;code&gt;requests&lt;/code&gt; library&lt;/a&gt;, then run the script:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; pip install requests
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; python caching.py
&lt;span class=&quot;go&quot;&gt;Getting article...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Fetching article from server...&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Getting article...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice how you get the string &lt;code&gt;&quot;Fetching article from server...&quot;&lt;/code&gt; &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;printed&lt;/a&gt; a single time despite calling &lt;code&gt;get_article()&lt;/code&gt; twice, in lines 17 and 18. This happens because, after accessing the article for the first time, you put its URL and content in the &lt;code&gt;cache&lt;/code&gt; dictionary. The second time, the code doesn’t need to fetch the item from the server again.&lt;/p&gt;
&lt;h3 id=&quot;caching-strategies&quot;&gt;Caching Strategies&lt;a class=&quot;headerlink&quot; href=&quot;#caching-strategies&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There’s one big problem with this cache implementation: the content of the dictionary will grow indefinitely! As the user downloads more articles, the application will keep storing them in memory, eventually causing the application to crash.&lt;/p&gt;
&lt;p&gt;To work around this issue, you need a strategy to decide which articles should stay in memory and which should be removed. These caching strategies are algorithms that focus on managing the cached information and choosing which items to discard to make room for new ones.&lt;/p&gt;
&lt;p&gt;There are several different strategies that you can use to evict items from the cache and keep it from growing past from its maximum size. Here are five of the most popular ones, with an explanation of when each is most useful:&lt;/p&gt;
&lt;div class=&quot;table-responsive&quot;&gt;
&lt;table class=&quot;table table-hover&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Eviction policy&lt;/th&gt;
&lt;th&gt;Use case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;First-In/First-Out (FIFO)&lt;/td&gt;
&lt;td&gt;Evicts the oldest of the entries&lt;/td&gt;
&lt;td&gt;Newer entries are most likely to be reused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Last-In/First-Out (LIFO)&lt;/td&gt;
&lt;td&gt;Evicts the latest of the entries&lt;/td&gt;
&lt;td&gt;Older entries are most likely to be reused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Least Recently Used (LRU)&lt;/td&gt;
&lt;td&gt;Evicts the least recently used entry&lt;/td&gt;
&lt;td&gt;Recently used entries are most likely to be reused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Most Recently Used (MRU)&lt;/td&gt;
&lt;td&gt;Evicts the most recently used entry&lt;/td&gt;
&lt;td&gt;Least recently used entries are most likely to be reused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Least Frequently Used (LFU)&lt;/td&gt;
&lt;td&gt;Evicts the least often accessed entry&lt;/td&gt;
&lt;td&gt;Entries with a lot of hits are more likely to be reused&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;In the sections below, you’ll take a closer look at the LRU strategy and how to implement it using the &lt;code&gt;@lru_cache&lt;/code&gt; decorator from Python’s &lt;code&gt;functools&lt;/code&gt; module.&lt;/p&gt;
&lt;h3 id=&quot;diving-into-the-least-recently-used-lru-cache-strategy&quot;&gt;Diving Into the Least Recently Used (LRU) Cache Strategy&lt;a class=&quot;headerlink&quot; href=&quot;#diving-into-the-least-recently-used-lru-cache-strategy&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/lru-cache-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/lru-cache-python/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Simulating Real-World Processes in Python With SimPy</title>
      <id>https://realpython.com/courses/simulating-processes-simpy/</id>
      <link href="https://realpython.com/courses/simulating-processes-simpy/"/>
      <updated>2020-11-03T14:00:00+00:00</updated>
      <summary>In this step-by-step course, you&#x27;ll see how you can use the SimPy package to model real-world processes with a high potential for congestion. You&#x27;ll create an algorithm to approximate a complex system, and then you&#x27;ll design and run a simulation of that system in Python.</summary>
      <content type="html">
        &lt;p&gt;The real world is full of systems, like airports and highways, that frequently experience congestion and delay. When these systems are not optimized, their inefficiency can lead to countless unhappy customers and hours of wasted time. In this course, you&amp;rsquo;ll learn how to use Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;simpy&lt;/code&gt;&lt;/strong&gt; framework to create virtual simulations that will help you solve problems like these.&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;&lt;strong&gt;Use&lt;/strong&gt; a simulation to model a real-world process&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create&lt;/strong&gt; a step-by-step algorithm to approximate a complex system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Design&lt;/strong&gt; and run a real-world simulation in Python with &lt;code&gt;simpy&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>Fourier Transforms With scipy.fft: Python Signal Processing</title>
      <id>https://realpython.com/python-scipy-fft/</id>
      <link href="https://realpython.com/python-scipy-fft/"/>
      <updated>2020-11-02T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to use the Fourier transform, a powerful tool for analyzing signals with applications ranging from audio processing to image compression. You&#x27;ll explore several different transforms provided by Python&#x27;s scipy.fft module.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The &lt;strong&gt;Fourier transform&lt;/strong&gt; is a powerful tool for analyzing &lt;strong&gt;signals&lt;/strong&gt; and is used in everything from audio processing to image compression. SciPy provides a mature implementation in its &lt;code&gt;scipy.fft&lt;/code&gt; module, and in this tutorial, you’ll learn how to use it.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;scipy.fft&lt;/code&gt; module may look intimidating at first since there are many functions, often with similar names, and the &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/tutorial/fft.html&quot;&gt;documentation&lt;/a&gt; uses a lot of technical terms without explanation. The good news is that you only need to understand a few core concepts to start using the module.&lt;/p&gt;
&lt;p&gt;Don’t worry if you’re not comfortable with math! You’ll get a feel for the algorithm through concrete examples, and there will be links to further resources if you want to dive into the equations. For a visual introduction to how the Fourier transform works, you might like &lt;a href=&quot;https://www.youtube.com/watch?v=spUNpyF58BY&quot;&gt;3Blue1Brown’s video&lt;/a&gt;.&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 and when to use the &lt;strong&gt;Fourier transform&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to select the correct function from &lt;strong&gt;&lt;code&gt;scipy.fft&lt;/code&gt;&lt;/strong&gt; for your use case&lt;/li&gt;
&lt;li&gt;How to view and modify the &lt;strong&gt;frequency spectrum&lt;/strong&gt; of a signal&lt;/li&gt;
&lt;li&gt;Which different &lt;strong&gt;transforms&lt;/strong&gt; are available in &lt;code&gt;scipy.fft&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you’d like a summary of this tutorial to keep after you finish reading, then download the cheat sheet below. It has explanations of all the functions in the &lt;code&gt;scipy.fft&lt;/code&gt; module as well as a breakdown of the different types of transform that are available:&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;scipy.fft Cheat Sheet:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/scipy-fft-cheatsheet/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-scipy-fft-cheatsheet&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get access to a free scipy.fft cheat sheet&lt;/a&gt; that summarizes the techniques explained in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;the-scipyfft-module&quot;&gt;The &lt;code&gt;scipy.fft&lt;/code&gt; Module&lt;a class=&quot;headerlink&quot; href=&quot;#the-scipyfft-module&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Fourier transform is a crucial tool in many applications, especially in scientific computing and data science. As such, SciPy has long provided an implementation of it and its related transforms. Initially, SciPy provided the &lt;code&gt;scipy.fftpack&lt;/code&gt; module, but they have since updated their implementation and moved it to the &lt;code&gt;scipy.fft&lt;/code&gt; module.&lt;/p&gt;
&lt;p&gt;SciPy is packed full of functionality. For a more general introduction to the library, check out &lt;a href=&quot;https://realpython.com/python-scipy-cluster-optimize/&quot;&gt;Scientific Python: Using SciPy for Optimization&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;install-scipy-and-matplotlib&quot;&gt;Install SciPy and Matplotlib&lt;a class=&quot;headerlink&quot; href=&quot;#install-scipy-and-matplotlib&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Before you can get started, you’ll need to install SciPy and &lt;a href=&quot;https://realpython.com/python-matplotlib-guide/&quot;&gt;Matplotlib&lt;/a&gt;. You can do this one of two ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install with Anaconda:&lt;/strong&gt; Download and install the &lt;a href=&quot;https://www.anaconda.com/products/individual&quot;&gt;Anaconda Individual Edition&lt;/a&gt;. It comes with SciPy and Matplotlib, so once you follow the steps in the installer, you’re done!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install with &lt;code&gt;pip&lt;/code&gt;:&lt;/strong&gt; If you already have &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt; installed, then you can install the libraries with the following command:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; python -m pip install -U scipy matplotlib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can verify the installation worked by &lt;a href=&quot;https://realpython.com/interacting-with-python/#using-the-python-interpreter-interactively&quot;&gt;typing &lt;code&gt;python&lt;/code&gt; in your terminal&lt;/a&gt; and running the following code:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;scipy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scipy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;vm&quot;&gt;__file__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/lib/python3.6/dist-packages/scipy/__init__.py&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matplotlib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;vm&quot;&gt;__file__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This code imports SciPy and Matplotlib and prints the location of the modules. Your computer will probably show different paths, but as long as it prints a path, the installation worked.&lt;/p&gt;
&lt;p&gt;SciPy is now installed! Now it’s time to take a look at the differences between &lt;code&gt;scipy.fft&lt;/code&gt; and &lt;code&gt;scipy.fftpack&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;scipyfft-vs-scipyfftpack&quot;&gt;&lt;code&gt;scipy.fft&lt;/code&gt; vs &lt;code&gt;scipy.fftpack&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#scipyfft-vs-scipyfftpack&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When looking at the SciPy documentation, you may come across two modules that look very similar:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;scipy.fft&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scipy.fftpack&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;scipy.fft&lt;/code&gt; module is newer and should be preferred over &lt;code&gt;scipy.fftpack&lt;/code&gt;. You can read more about the change in the &lt;a href=&quot;https://docs.scipy.org/doc/scipy/reference/release.1.4.0.html#scipy-fft-added&quot;&gt;release notes for SciPy 1.4.0&lt;/a&gt;, but here’s a quick summary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scipy.fft&lt;/code&gt; has an improved API.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scipy.fft&lt;/code&gt; enables using &lt;a href=&quot;https://realpython.com/intro-to-python-threading/&quot;&gt;multiple workers&lt;/a&gt;, which can provide a speed boost in some situations.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scipy.fftpack&lt;/code&gt; is considered legacy, and SciPy recommends using &lt;code&gt;scipy.fft&lt;/code&gt; instead.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Unless you have a good reason to use &lt;code&gt;scipy.fftpack&lt;/code&gt;, you should stick with &lt;code&gt;scipy.fft&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;scipyfft-vs-numpyfft&quot;&gt;&lt;code&gt;scipy.fft&lt;/code&gt; vs &lt;code&gt;numpy.fft&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#scipyfft-vs-numpyfft&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;SciPy’s &lt;a href=&quot;https://en.wikipedia.org/wiki/Fast_Fourier_transform&quot;&gt;fast Fourier transform (FFT)&lt;/a&gt; implementation contains more features and is more likely to get bug fixes than NumPy’s implementation. If given a choice, you should use the SciPy implementation.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-scipy-fft/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-scipy-fft/ »&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 #33: Going Beyond the Basic Stuff With Python and Al Sweigart</title>
      <id>https://realpython.com/podcasts/rpp/33/</id>
      <link href="https://realpython.com/podcasts/rpp/33/"/>
      <updated>2020-10-30T12:00:00+00:00</updated>
      <summary>You probably have heard of the bestselling Python book, &quot;Automate the Boring Stuff with Python.&quot;  What are the next steps after starting to dabble in the Python basics? Maybe you&#x27;ve completed some tutorials, created a few scripts, and automated repetitive tasks in your life. This week on the show, we have author Al Sweigart to talk about his new book, &quot;Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code.&quot;</summary>
      <content type="html">
        &lt;p&gt;You probably have heard of the bestselling Python book, &quot;Automate the Boring Stuff with Python.&quot;  What are the next steps after starting to dabble in the Python basics? Maybe you&#x27;ve completed some tutorials, created a few scripts, and automated repetitive tasks in your life. This week on the show, we have author Al Sweigart to talk about his new book, &quot;Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code.&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>Creating a Binary Search in Python</title>
      <id>https://realpython.com/courses/creating-binary-search-python/</id>
      <link href="https://realpython.com/courses/creating-binary-search-python/"/>
      <updated>2020-10-27T14:00:00+00:00</updated>
      <summary>Binary search is a classic algorithm in computer science. In this step-by-step course, you&#x27;ll learn how to implement this algorithm in Python. You&#x27;ll learn how to leverage existing libraries as well as craft your own binary search Python implementation.</summary>
      <content type="html">
        &lt;p&gt;&lt;strong&gt;Binary search&lt;/strong&gt; is a classic algorithm in computer science. It often comes up in programming contests and &lt;a href=&quot;https://realpython.com/python-coding-interview-tips/&quot;&gt;technical interviews&lt;/a&gt;. Implementing binary search turns out to be a challenging task, even when you understand the concept. Unless you&amp;rsquo;re curious or have a specific assignment, you should always leverage existing libraries to do a binary search in Python or any other language.&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 the &lt;strong&gt;&lt;code&gt;bisect&lt;/code&gt;&lt;/strong&gt; module to do a binary search in Python&lt;/li&gt;
&lt;li&gt;Implement a binary search in Python both &lt;strong&gt;recursively&lt;/strong&gt; and &lt;strong&gt;iteratively&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Recognize and fix &lt;strong&gt;defects&lt;/strong&gt; in a binary search Python implementation&lt;/li&gt;
&lt;li&gt;Analyze the &lt;strong&gt;time-space complexity&lt;/strong&gt; of the binary search algorithm&lt;/li&gt;
&lt;li&gt;Search even &lt;strong&gt;faster&lt;/strong&gt; than binary search&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This course assumes you&amp;rsquo;re a student or an &lt;a href=&quot;https://realpython.com/tutorials/intermediate/&quot;&gt;&lt;strong&gt;intermediate programmer&lt;/strong&gt;&lt;/a&gt; with an interest in algorithms and &lt;a href=&quot;https://realpython.com/python-data-structures/&quot;&gt;data structures&lt;/a&gt;. At the very least, you should be familiar with Python&amp;rsquo;s &lt;a href=&quot;https://realpython.com/python-data-types/&quot;&gt;built-in data types&lt;/a&gt;, such as &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;lists and tuples&lt;/a&gt;. In addition, some familiarity with &lt;a href=&quot;https://realpython.com/python-thinking-recursively/&quot;&gt;recursion&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/lessons/classes-python/&quot;&gt;classes&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-data-classes/&quot;&gt;data classes&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-lambda/&quot;&gt;lambdas&lt;/a&gt; will help you better understand the concepts you&amp;rsquo;ll see in this course.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #32: Our New &quot;Python Basics&quot; Book &amp; Filling the Gaps in Your Learning Path</title>
      <id>https://realpython.com/podcasts/rpp/32/</id>
      <link href="https://realpython.com/podcasts/rpp/32/"/>
      <updated>2020-10-23T12:00:00+00:00</updated>
      <summary>Do you have gaps in your Python learning path? If you&#x27;re like me, you may have followed a completely random route to learn Python. This week on the show, David Amos is here to talk about the release of the Real Python book, &quot;Python Basics: A Practical Introduction to Python 3&quot;. The book is designed not only to get beginners up to speed but also to help fill in the gaps many intermediate learners may still have.</summary>
      <content type="html">
        &lt;p&gt;Do you have gaps in your Python learning path? If you&#x27;re like me, you may have followed a completely random route to learn Python. This week on the show, David Amos is here to talk about the release of the Real Python book, &quot;Python Basics: A Practical Introduction to Python 3&quot;. The book is designed not only to get beginners up to speed but also to help fill in the gaps many intermediate learners may still have.&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>Getting Started With MicroPython</title>
      <id>https://realpython.com/courses/getting-started-micropython/</id>
      <link href="https://realpython.com/courses/getting-started-micropython/"/>
      <updated>2020-10-20T14:00:00+00:00</updated>
      <summary>Are you interested in the Internet of Things, home automation, and connected devices? If so, then you&#x27;re in luck! In this course, you&#x27;ll learn about MicroPython and the world of electronics hardware. You&#x27;ll set up your board, write your code, and deploy a MicroPython project to your own device.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in the Internet of Things, home automation, and connected devices? Have you ever wondered what it would be like to build a blaster, a laser sword, or even your own robot? If so, then you&amp;rsquo;re in luck! &lt;strong&gt;MicroPython&lt;/strong&gt; can help you do all of those things and more.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;history&lt;/strong&gt; of MicroPython&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;differences&lt;/strong&gt; between MicroPython and other programming languages&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;hardware&lt;/strong&gt; you&amp;rsquo;ll use to build devices&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;process&lt;/strong&gt; to set up, code, and deploy your own MicroPython project&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 #31: Python Return Statement Best Practices and Working With the map() Function</title>
      <id>https://realpython.com/podcasts/rpp/31/</id>
      <link href="https://realpython.com/podcasts/rpp/31/"/>
      <updated>2020-10-16T12:00:00+00:00</updated>
      <summary>The Python return statement is such a fundamental part of writing functions. Is it possible you missed some best practices when writing your own return statements? This week on the show, David Amos returns with another batch of PyCoder’s Weekly articles and projects. We also talk functional programming again with an article on the Python map function and processing iterables without a loop.</summary>
      <content type="html">
        &lt;p&gt;The Python return statement is such a fundamental part of writing functions. Is it possible you missed some best practices when writing your own return statements? This week on the show, David Amos returns with another batch of PyCoder’s Weekly articles and projects. We also talk functional programming again with an article on the Python map function and processing iterables without a loop.&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>Web Scraping With Beautiful Soup and Python</title>
      <id>https://realpython.com/courses/web-scraping-beautiful-soup/</id>
      <link href="https://realpython.com/courses/web-scraping-beautiful-soup/"/>
      <updated>2020-10-13T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll walk through the main steps of the web scraping process. You&#x27;ll learn how to write a script that uses Python&#x27;s requests library to scrape data from a website. You&#x27;ll also use Beautiful Soup to extract the specific pieces of information that you&#x27;re interested in.</summary>
      <content type="html">
        &lt;p&gt;The incredible amount of data on the Internet is a rich resource for any field of research or personal interest. To effectively harvest that data, you&amp;rsquo;ll need to become skilled at &lt;a href=&quot;https://realpython.com/python-web-scraping-practical-introduction/&quot;&gt;&lt;strong&gt;web scraping&lt;/strong&gt;&lt;/a&gt;. The Python libraries &lt;code&gt;requests&lt;/code&gt; and Beautiful Soup are powerful tools for the job. If you like to learn with hands-on examples and you have a basic understanding of Python and HTML, then this course is for you.&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;code&gt;requests&lt;/code&gt; and Beautiful Soup for &lt;strong&gt;scraping and parsing data&lt;/strong&gt; from the Web&lt;/li&gt;
&lt;li&gt;Walk through a &lt;strong&gt;web scraping pipeline&lt;/strong&gt; from start to finish&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Build a script&lt;/strong&gt; that fetches job offers from the Web and displays relevant information in your console&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 #30: Exploring the New Features of Python 3.9</title>
      <id>https://realpython.com/podcasts/rpp/30/</id>
      <link href="https://realpython.com/podcasts/rpp/30/"/>
      <updated>2020-10-09T12:00:00+00:00</updated>
      <summary>Python 3.9 has arrived! This week on the show, former guest and Real Python author Geir Arne Hjelle returns to talk about his recent article, &quot;Python 3.9: Cool New Features for You to Try&quot;. Also joining the conversation is Real Python video course instructor and author Christopher Trudeau. Christopher has created a video course, which was released this week also, based on Geir Arne&#x27;s article. We talk about time zones, merging dictionaries, the new parser, type hints, and more.</summary>
      <content type="html">
        &lt;p&gt;Python 3.9 has arrived! This week on the show, former guest and Real Python author Geir Arne Hjelle returns to talk about his recent article, &quot;Python 3.9: Cool New Features for You to Try&quot;. Also joining the conversation is Real Python video course instructor and author Christopher Trudeau. Christopher has created a video course, which was released this week also, based on Geir Arne&#x27;s article. We talk about time zones, merging dictionaries, the new parser, type hints, and more.&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>Cool New Features in Python 3.9</title>
      <id>https://realpython.com/courses/cool-new-features-python-39/</id>
      <link href="https://realpython.com/courses/cool-new-features-python-39/"/>
      <updated>2020-10-06T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll explore some of the coolest and most useful features in the newly released Python 3.9. You&#x27;ll learn how Python 3.9 makes it easier to work with time zones, dictionaries, decorators, and several other techniques that will make your code cleaner and more efficient.</summary>
      <content type="html">
        &lt;p&gt;Python 3.9 is here! Volunteers from all over the world have been working on improvements to Python for the past year. While beta versions have been available for some time, the first official version of Python 3.9 was released on &lt;a href=&quot;https://www.python.org/dev/peps/pep-0596/&quot;&gt;October 5, 2020&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Every release of Python includes new, improved, and deprecated features, and Python 3.9 is no different. The &lt;a href=&quot;https://docs.python.org/3.9/whatsnew/3.9.html&quot;&gt;documentation&lt;/a&gt; gives a complete list of the changes. Below, you&amp;rsquo;ll take an in-depth look at the coolest features that the latest version of Python brings to the table.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you&amp;rsquo;ll learn about:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Accessing and calculating with &lt;strong&gt;time zones&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Merging and updating &lt;strong&gt;dictionaries&lt;/strong&gt; effectively&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;decorators&lt;/strong&gt; based on &lt;strong&gt;expressions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Combining &lt;strong&gt;type hints&lt;/strong&gt; and &lt;strong&gt;other annotations&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Bonus Learning Materials:&lt;/strong&gt; Check out &lt;a href=&quot;https://realpython.com/podcasts/rpp/30/&quot;&gt;Real Python Podcast Episode #30&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/lessons/office-hours-2020-10-21/&quot;&gt;this Office Hours recording&lt;/a&gt; with Python 3.9 tips and a panel discussion with members of the Real Python Team.&lt;/p&gt;
&lt;/div&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #29: Resolving Package Dependencies With the New Version of Pip</title>
      <id>https://realpython.com/podcasts/rpp/29/</id>
      <link href="https://realpython.com/podcasts/rpp/29/"/>
      <updated>2020-10-02T12:00:00+00:00</updated>
      <summary>If you use Python, then you probably have used pip to install additional packages from the Python package index. Part of the magic behind pip is the dependency resolver, and there is a new version of it in the latest version of pip. This week on the show, we have Sumana Harihareswara and Georgia Bullen, who have been working on the recent releases of pip. Sumana is the project manager for pip, and Georgia has been working on pip&#x27;s user experience (UX).</summary>
      <content type="html">
        &lt;p&gt;If you use Python, then you probably have used pip to install additional packages from the Python package index. Part of the magic behind pip is the dependency resolver, and there is a new version of it in the latest version of pip. This week on the show, we have Sumana Harihareswara and Georgia Bullen, who have been working on the recent releases of pip. Sumana is the project manager for pip, and Georgia has been working on pip&#x27;s user experience (UX).&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Using Google Login With Flask</title>
      <id>https://realpython.com/courses/using-google-login-flask/</id>
      <link href="https://realpython.com/courses/using-google-login-flask/"/>
      <updated>2020-09-29T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll create a Flask application that lets users sign in using their Google login. You&#x27;ll learn about OAuth 2 and OpenID Connect and also find out how to implement some code to handle user session management.</summary>
      <content type="html">
        &lt;p&gt;In this course, you&amp;rsquo;ll work through the creation of a &lt;a href=&quot;https://realpython.com/tutorials/flask/&quot;&gt;Flask&lt;/a&gt; web application. Your application will allow a user to log in using their Google identity instead of creating a new account. There are tons of benefits with this method of user management. It&amp;rsquo;s going to be safer and simpler than managing the traditional username and password combinations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this course, you&amp;rsquo;ll be able to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a &lt;strong&gt;Flask web application&lt;/strong&gt; that lets users log in with Google&lt;/li&gt;
&lt;li&gt;Create &lt;strong&gt;client credentials&lt;/strong&gt; to interact with Google&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Flask-Login&lt;/strong&gt; for user session management in a Flask application&lt;/li&gt;
&lt;li&gt;Better understand &lt;strong&gt;OAuth 2 and OpenID Connect&lt;/strong&gt; (OIDC)&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 #28: Using Pylance to Write Better Python Inside of Visual Studio Code</title>
      <id>https://realpython.com/podcasts/rpp/28/</id>
      <link href="https://realpython.com/podcasts/rpp/28/"/>
      <updated>2020-09-25T12:00:00+00:00</updated>
      <summary>A big decision a developer has to make is what tool to use to write code? Would you like an editor that understands Python, and is there to help with suggestions, definitions, and analysis of your code? For many developers, its the free tool, Visual Studio Code. This week on the show, we have Savannah Ostrowski, program manager for the Python Language Server and Python in Visual Studio. We discuss Pylance, a new language server with fast, feature-rich language support for Python in VS Code.</summary>
      <content type="html">
        &lt;p&gt;A big decision a developer has to make is what tool to use to write code? Would you like an editor that understands Python, and is there to help with suggestions, definitions, and analysis of your code? For many developers, its the free tool, Visual Studio Code. This week on the show, we have Savannah Ostrowski, program manager for the Python Language Server and Python in Visual Studio. We discuss Pylance, a new language server with fast, feature-rich language support for Python in VS Code.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  

</feed>
