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

  
    <entry>
      <title>Functional Programming in Python: When and How to Use It</title>
      <id>https://realpython.com/python-functional-programming/</id>
      <link href="https://realpython.com/python-functional-programming/"/>
      <updated>2021-02-17T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn about functional programming in Python.  You&#x27;ll see what functional programming is, how it&#x27;s supported in Python, and how you can use it in your Python code.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;strong&gt;Functional programming&lt;/strong&gt; is a programming paradigm in which the primary method of computation is evaluation of functions. In this tutorial, you’ll explore functional programming in Python.&lt;/p&gt;
&lt;p&gt;Functional programming typically plays a fairly small role in Python code. But it’s good to be familiar with it. At a minimum, you’ll probably encounter it from time to time when reading code written by others. You may even find situations where it’s advantageous to use Python’s functional programming capabilities in your own 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 the &lt;strong&gt;functional programming&lt;/strong&gt; paradigm entails&lt;/li&gt;
&lt;li&gt;What it means to say that &lt;strong&gt;functions&lt;/strong&gt; are &lt;strong&gt;first-class citizens&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;How to define &lt;strong&gt;anonymous functions&lt;/strong&gt; with the &lt;strong&gt;&lt;code&gt;lambda&lt;/code&gt;&lt;/strong&gt; keyword&lt;/li&gt;
&lt;li&gt;How to implement functional code using &lt;strong&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;code&gt;reduce()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;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;what-is-functional-programming&quot;&gt;What Is Functional Programming?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-functional-programming&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;pure function&lt;/strong&gt; is a function whose output value follows solely from its input values, without any observable &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/#side-effects&quot;&gt;side effects&lt;/a&gt;. In &lt;strong&gt;functional programming&lt;/strong&gt;, a program consists entirely of evaluation of pure functions. Computation proceeds by nested or &lt;a href=&quot;https://en.wikipedia.org/wiki/Function_composition_(computer_science)&quot;&gt;composed function calls&lt;/a&gt;, without changes to state or mutable data.&lt;/p&gt;
&lt;p&gt;The functional paradigm is popular because it offers several advantages over other programming paradigms. Functional code is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;High level:&lt;/strong&gt; You’re describing the result you want rather than explicitly specifying the steps required to get there. Single statements tend to be concise but pack a lot of punch.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transparent:&lt;/strong&gt; The behavior of a pure function depends only on its inputs and outputs, without intermediary values. That eliminates the possibility of side effects, which facilitates &lt;a href=&quot;https://realpython.com/python-debugging-pdb/&quot;&gt;debugging&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallelizable:&lt;/strong&gt; Routines that don’t cause side effects can more easily &lt;a href=&quot;https://realpython.com/learning-paths/python-concurrency-parallel-programming/&quot;&gt;run in parallel&lt;/a&gt; with one another.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Many programming languages support some degree of functional programming. In some languages, virtually all code follows the functional paradigm. &lt;a href=&quot;https://www.haskell.org&quot;&gt;Haskell&lt;/a&gt; is one such example. Python, by contrast, does support functional programming but contains features of other programming models as well.&lt;/p&gt;
&lt;p&gt;While it’s true that an in-depth &lt;a href=&quot;https://en.wikipedia.org/wiki/Functional_programming&quot;&gt;description of functional programming&lt;/a&gt; is somewhat complex, the goal here isn’t to present a rigorous definition but to show you what you can do by way of functional programming in Python.&lt;/p&gt;
&lt;h2 id=&quot;how-well-does-python-support-functional-programming&quot;&gt;How Well Does Python Support Functional Programming?&lt;a class=&quot;headerlink&quot; href=&quot;#how-well-does-python-support-functional-programming&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To support functional programming, it’s useful if a &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;function&lt;/a&gt; in a given programming language has two abilities:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;To take another function as an argument&lt;/li&gt;
&lt;li&gt;To return another function to its caller&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Python plays nicely in both these respects. As you’ve learned previously in this series, &lt;a href=&quot;https://realpython.com/python-variables/#object-references&quot;&gt;everything in a Python program is an object&lt;/a&gt;. All objects in Python have more or less equal stature, and functions are no exception.&lt;/p&gt;
&lt;p&gt;In Python, functions are &lt;strong&gt;first-class citizens&lt;/strong&gt;. That means functions have the same characteristics as values like &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;strings&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt;. Anything you would expect to be able to do with a string or number you can do with a function as well.&lt;/p&gt;
&lt;p&gt;For example, you can assign a function to a variable. You can then use that variable the same as you would use the function itself:&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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;I am function func()!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;I am function func()!&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;another_name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;another_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;I am function func()!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The assignment &lt;code&gt;another_name = func&lt;/code&gt; on line 8 creates a new reference to &lt;code&gt;func()&lt;/code&gt; named &lt;code&gt;another_name&lt;/code&gt;. You can then call the function by either name, &lt;code&gt;func&lt;/code&gt; or &lt;code&gt;another_name&lt;/code&gt;, as shown on lines 5 and 9.&lt;/p&gt;
&lt;p&gt;You can display a function to the console with &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;&lt;code&gt;print()&lt;/code&gt;&lt;/a&gt;, include it as an element in a composite data object like a &lt;a href=&quot;https://realpython.com/python-lists-tuples/&quot;&gt;list&lt;/a&gt;, or even use it as a &lt;a href=&quot;https://realpython.com/python-dicts/&quot;&gt;dictionary&lt;/a&gt; key:&lt;/p&gt;
&lt;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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;I am function func()!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;cat &amp;lt;function func at 0x7f81b4d29bf8&amp;gt; 42&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;function func at 0x7f81b4d29bf8&amp;gt;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;I am function func()!&lt;/span&gt;

&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, &lt;code&gt;func()&lt;/code&gt; appears in all the same contexts as the values &lt;code&gt;&quot;cat&quot;&lt;/code&gt; and &lt;code&gt;42&lt;/code&gt;, and the interpreter handles it just fine.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; What you can or can’t do with any object in Python depends to some extent on context. There are some operations, for example, that work for certain object types but not for others. &lt;/p&gt;
&lt;p&gt;You can add two integer objects or concatenate two string objects with the plus operator (&lt;code&gt;+&lt;/code&gt;). But the plus operator isn’t defined for function objects.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;For present purposes, what matters is that functions in Python satisfy the two criteria beneficial for functional programming listed above. You can pass a function to another function as an argument:&lt;/p&gt;
&lt;div 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;linenos&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;I am function inner()!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 3&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 4&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;outer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 7&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 8&lt;/span&gt;
&lt;span class=&quot;linenos&quot;&gt; 9&lt;/span&gt;&lt;span class=&quot;hll&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class=&quot;linenos&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;go&quot;&gt;I am function inner()!&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-functional-programming/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-functional-programming/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Creating PyQt Layouts for GUI Applications</title>
      <id>https://realpython.com/courses/creating-pyqt-layouts-gui-applications/</id>
      <link href="https://realpython.com/courses/creating-pyqt-layouts-gui-applications/"/>
      <updated>2021-02-16T14:00:00+00:00</updated>
      <summary>In this step-by-step course, 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;p&gt;PyQt&amp;rsquo;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 course, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What the benefits are of using PyQt&amp;rsquo;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&amp;rsquo;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&amp;ndash;based&lt;/strong&gt; and &lt;strong&gt;dialog-based&lt;/strong&gt; applications&lt;/li&gt;
&lt;/ul&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;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>Pandas Sort: Your Guide to Sorting Data in Python</title>
      <id>https://realpython.com/pandas-sort-python/</id>
      <link href="https://realpython.com/pandas-sort-python/"/>
      <updated>2021-02-15T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to sort data in a pandas DataFrame using the pandas sort functions sort_values() and sort_index(). You&#x27;ll learn how to sort by one or more columns and by index in ascending or descending order.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Learning pandas &lt;strong&gt;sort methods&lt;/strong&gt; is a great way to start with or practice doing basic &lt;a href=&quot;https://realpython.com/pandas-python-explore-dataset/&quot;&gt;data analysis using Python&lt;/a&gt;. Most commonly, data analysis is done with &lt;a href=&quot;https://realpython.com/openpyxl-excel-spreadsheets-python/&quot;&gt;spreadsheets&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/python-sql-libraries/&quot;&gt;SQL&lt;/a&gt;, or &lt;a href=&quot;https://realpython.com/learning-paths/pandas-data-science/&quot;&gt;pandas&lt;/a&gt;. One of the great things about using pandas is that it can handle a large amount of data and offers highly performant data manipulation capabilities.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn how to use &lt;code&gt;.sort_values()&lt;/code&gt; and &lt;code&gt;.sort_index()&lt;/code&gt;, which will enable you to sort data efficiently in a DataFrame.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll know how to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sort a &lt;strong&gt;pandas DataFrame&lt;/strong&gt; by the values of one or more columns&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;ascending&lt;/code&gt; parameter to change the &lt;strong&gt;sort order&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Sort a DataFrame by its &lt;code&gt;index&lt;/code&gt; using &lt;strong&gt;&lt;code&gt;.sort_index()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Organize &lt;strong&gt;missing data&lt;/strong&gt; while sorting values&lt;/li&gt;
&lt;li&gt;Sort a DataFrame &lt;strong&gt;in place&lt;/strong&gt; using &lt;code&gt;inplace&lt;/code&gt; set to &lt;code&gt;True&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To follow along with this tutorial, you’ll need a basic understanding of &lt;a href=&quot;https://www.realpython.com/pandas-dataframe/&quot;&gt;pandas DataFrames&lt;/a&gt; and some familiarity with &lt;a href=&quot;https://realpython.com/python-csv/#reading-csv-files-with-pandas&quot;&gt;reading in data from files&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-python-cheat-sheet-shortened&quot; data-focus=&quot;false&quot;&gt;Click here to get a Python Cheat Sheet&lt;/a&gt; and learn the basics of Python 3, like working with data types, dictionaries, lists, and Python functions.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;getting-started-with-pandas-sort-methods&quot;&gt;Getting Started With Pandas Sort Methods&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-pandas-sort-methods&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As a quick reminder, a &lt;strong&gt;DataFrame&lt;/strong&gt; is a data structure with labeled axes for both rows and columns. You can sort a DataFrame by row or column value as well as by row or column index. &lt;/p&gt;
&lt;p&gt;Both rows and columns have &lt;strong&gt;indices&lt;/strong&gt;, which are numerical representations of where the data is in your DataFrame. You can retrieve data from specific rows or columns using the DataFrame’s index locations. By default, index numbers start from zero. You can also manually assign your own index.&lt;/p&gt;
&lt;h3 id=&quot;preparing-the-dataset&quot;&gt;Preparing the Dataset&lt;a class=&quot;headerlink&quot; href=&quot;#preparing-the-dataset&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In this tutorial, you’ll be working with fuel economy data compiled by the US Environmental Protection Agency (EPA) on vehicles made between 1984 and 2021. The &lt;a href=&quot;https://www.fueleconomy.gov/feg/download.shtml&quot;&gt;EPA fuel economy dataset&lt;/a&gt; is great because it has many different types of information that you can sort on, from textual to numeric data types. The dataset contains eighty-three columns in total. &lt;/p&gt;
&lt;p&gt;To follow along, you’ll need to have the &lt;a href=&quot;https://pandas.pydata.org/&quot;&gt;pandas&lt;/a&gt; Python library installed. The code in this tutorial was executed using pandas 1.2.0 and &lt;a href=&quot;https://www.python.org/downloads/release/python-391/&quot;&gt;Python 3.9.1&lt;/a&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 whole fuel economy dataset is around 18 MB. Reading the entire dataset into memory could take a minute or two. Limiting the number of rows and columns will help performance, but it will still take a few seconds before the data is downloaded.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;For analysis purposes, you’ll be looking at MPG (miles per gallon) data on vehicles by make, model, year, and other vehicle attributes. You can specify which columns to read into your DataFrame. For this tutorial, you’ll need only a subset of the &lt;a href=&quot;https://www.fueleconomy.gov/feg/ws/index.shtml#vehicle&quot;&gt;available columns&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here are the commands to read the relevant columns of the fuel economy dataset into a DataFrame and to display the first five rows:&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;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pd&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;column_subset&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;make&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;model&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;cylinders&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;fuelType&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;trany&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;mpgData&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;city08&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;s2&quot;&gt;&quot;highway08&quot;&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_csv&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;s2&quot;&gt;&quot;https://www.fueleconomy.gov/feg/epadata/vehicles.csv&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;usecols&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;column_subset&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;nrows&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;   city08  cylinders fuelType  ...  mpgData            trany  year&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;0      19          4  Regular  ...        Y     Manual 5-spd  1985&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;1       9         12  Regular  ...        N     Manual 5-spd  1985&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;2      23          4  Regular  ...        Y     Manual 5-spd  1985&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;3      10          8  Regular  ...        N  Automatic 3-spd  1985&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;4      17          4  Premium  ...        N     Manual 5-spd  1993&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;[5 rows x 10 columns]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By calling &lt;code&gt;.read_csv()&lt;/code&gt; with the dataset URL, you’re able to load the data into a DataFrame. Narrowing down the columns results in faster load times and lower memory use. To further limit memory consumption and to get a quick feel for the data, you can specify how many rows to load using &lt;code&gt;nrows&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;getting-familiar-with-sort_values&quot;&gt;Getting Familiar With &lt;code&gt;.sort_values()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#getting-familiar-with-sort_values&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You use &lt;a href=&quot;https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html&quot;&gt;&lt;code&gt;.sort_values()&lt;/code&gt;&lt;/a&gt; to sort values in a DataFrame along either axis (columns or rows). Typically, you want to sort the rows in a DataFrame by the values of one or more columns:&lt;/p&gt;
&lt;figure&gt;&lt;a href=&quot;https://files.realpython.com/media/dataframe-values-sort.62a6327755df.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/dataframe-values-sort.62a6327755df.png&quot; width=&quot;1004&quot; height=&quot;547&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/dataframe-values-sort.62a6327755df.png&amp;amp;w=251&amp;amp;sig=4faa9dcb7aa400dc0c409721fab10b998f520a60 251w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/dataframe-values-sort.62a6327755df.png&amp;amp;w=502&amp;amp;sig=36ad798b1404a2b56402ed4fe27705a743dfb910 502w, https://files.realpython.com/media/dataframe-values-sort.62a6327755df.png 1004w&quot; sizes=&quot;75vw&quot; alt=&quot;Pandas DataFrame Sorted by Column Values&quot; data-asset=&quot;3430&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;The figure above shows the results of using &lt;code&gt;.sort_values()&lt;/code&gt; to sort the DataFrame’s rows based on the values in the &lt;code&gt;highway08&lt;/code&gt; column. This is similar to how you would sort data in a spreadsheet using a column.&lt;/p&gt;
&lt;h3 id=&quot;getting-familiar-with-sort_index&quot;&gt;Getting Familiar With &lt;code&gt;.sort_index()&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#getting-familiar-with-sort_index&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You use &lt;code&gt;.sort_index()&lt;/code&gt; to sort a DataFrame by its row index or column labels. The difference from using &lt;code&gt;.sort_values()&lt;/code&gt; is that you’re sorting the DataFrame based on its row index or column names, not by the values in these rows or columns:&lt;/p&gt;
&lt;figure&gt;&lt;a href=&quot;https://files.realpython.com/media/dataframe-row-index.d6aa0bd658aa.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/dataframe-row-index.d6aa0bd658aa.png&quot; width=&quot;1020&quot; height=&quot;560&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/dataframe-row-index.d6aa0bd658aa.png&amp;amp;w=255&amp;amp;sig=b61058ae50297e41ef020b0648539179badb6242 255w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/dataframe-row-index.d6aa0bd658aa.png&amp;amp;w=510&amp;amp;sig=a4f2a1bdcab30f5d3b95ff12b63d3f9955083569 510w, https://files.realpython.com/media/dataframe-row-index.d6aa0bd658aa.png 1020w&quot; sizes=&quot;75vw&quot; alt=&quot;Pandas DataFrame Sorted by Row Index&quot; data-asset=&quot;3431&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;The row index of the DataFrame is outlined in blue in the figure above. An index isn’t considered a column, and you typically have only a single row index. The row index can be thought of as the row numbers, which start from zero.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/pandas-sort-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/pandas-sort-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 #47: Unraveling Python&#x27;s Syntax to Its Core With Brett Cannon</title>
      <id>https://realpython.com/podcasts/rpp/47/</id>
      <link href="https://realpython.com/podcasts/rpp/47/"/>
      <updated>2021-02-12T12:00:00+00:00</updated>
      <summary>Do you feel like you understand how Python works under the hood? What is syntactic sugar, and how much of it should be in Python? This week on the show, we have Brett Cannon. Brett is a Python core developer and he&#x27;s been working on a series of articles where he is unraveling the syntax of Python. His series is a fantastic resource for those wanting to learn how Python is structured and works at its core.</summary>
      <content type="html">
        &lt;p&gt;Do you feel like you understand how Python works under the hood? What is syntactic sugar, and how much of it should be in Python? This week on the show, we have Brett Cannon. Brett is a Python core developer and he&#x27;s been working on a series of articles where he is unraveling the syntax of Python. His series is a fantastic resource for those wanting to learn how Python is structured and works at its core.&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 Microservices With gRPC</title>
      <id>https://realpython.com/python-microservices-grpc/</id>
      <link href="https://realpython.com/python-microservices-grpc/"/>
      <updated>2021-02-10T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn how to build a robust and developer-friendly Python microservices infrastructure. You&#x27;ll learn what microservices are and how you can implement them using gRPC and Kubernetes. You&#x27;ll also explore advanced topics such as interceptors and integration testing.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;strong&gt;Microservices&lt;/strong&gt; are a way to organize complex software systems. Instead of putting all your code into one app, you break your app into microservices that are deployed independently and communicate with each other. This tutorial teaches you how to get up and running with Python microservices using gRPC, one of the most popular frameworks.&lt;/p&gt;
&lt;p&gt;Implementing a microservices framework well is important. When you’re building a framework to support critical applications, you must ensure it’s robust and developer-friendly. In this tutorial, you’ll learn how to do just that. This knowledge will make you more valuable to growing companies. &lt;/p&gt;
&lt;p&gt;In order to benefit most from this tutorial, you should understand the &lt;a href=&quot;https://realpython.com/tutorials/basics/&quot;&gt;basics of Python&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/flask-by-example-part-1-project-setup/&quot;&gt;web apps&lt;/a&gt;. If you’d like a refresher on those, read through the links provided first.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll be able to:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement &lt;strong&gt;microservices&lt;/strong&gt; in Python that communicate with one another over gRPC&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;middleware&lt;/strong&gt; to monitor microservices&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unit test&lt;/strong&gt; and &lt;strong&gt;integration test&lt;/strong&gt; your microservices and middleware&lt;/li&gt;
&lt;li&gt;Deploy microservices to a Python production environment with &lt;strong&gt;Kubernetes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can download all the source code used in this tutorial by clicking 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/python-microservices-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-microservices-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 creating Python microservices with gRPC in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;why-microservices&quot;&gt;Why Microservices?&lt;a class=&quot;headerlink&quot; href=&quot;#why-microservices&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine you work at Online Books For You, a popular e-commerce site that sells books online. The company has several hundred developers. Each developer is writing code for some product or back-end feature, such as managing the user’s cart, generating recommendations, handling payment transactions, or dealing with warehouse inventory.&lt;/p&gt;
&lt;p&gt;Now ask yourself, would you want all that code in one giant application? How hard would that be to understand? How long would it take to test? How would you keep the code and database schemas sane? It definitely would be hard, especially as the business tries to move quickly.&lt;/p&gt;
&lt;p&gt;Wouldn’t you rather have code corresponding to modular product features be, well, modular? A cart microservice to manage carts. An inventory microservice to manage inventory.&lt;/p&gt;
&lt;p&gt;In the sections below, you’ll dig a bit deeper into some reasons to separate Python code into microservices.&lt;/p&gt;
&lt;h3 id=&quot;modularity&quot;&gt;Modularity&lt;a class=&quot;headerlink&quot; href=&quot;#modularity&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Code changes often take the path of least resistance. Your beloved Online Books For You CEO wants to add a new buy-two-books-get-one-free feature. You’re part of the team that’s been asked to launch it as quickly as possible. Take a look at what happens when all your code is in a single application.&lt;/p&gt;
&lt;p&gt;Being the smartest engineer on your team, you mention that you can add some code to the cart logic to check if there are more than two books in the cart. If so, you can simply subtract the cost of the cheapest book from the cart total. No sweat—you make a pull request. &lt;/p&gt;
&lt;p&gt;Then your product manager says you need to track this campaign’s impact on books sales. This is pretty straightforward, too. Since the logic that implements the buy-two-get-one feature is in the cart code, you’ll add a line in the checkout flow that updates a new column on the transactions database to indicate the sale was part of the promotion: &lt;code&gt;buy_two_get_one_free_promo = true&lt;/code&gt;. Done. &lt;/p&gt;
&lt;p&gt;Next, your product manager reminds you that the deal is valid for only one use per customer. You need to add some logic to check whether any previous transactions had that &lt;code&gt;buy_two_get_one_free_promo&lt;/code&gt; flag set. Oh, and you need to hide the promotion banner on the home page, so you add that check, too. Oh, and you need to send emails to people who haven’t used the promo. Add that, too.&lt;/p&gt;
&lt;p&gt;Several years later, the transactions database has grown too large and needs to be replaced with a new shared database. All those references need to be changed. Unfortunately, the database is referenced all over the codebase at this point. You consider that it was actually a little &lt;em&gt;too&lt;/em&gt; easy to add all those references.&lt;/p&gt;
&lt;p&gt;That’s why having all your code in a single application can be dangerous in the long run. Sometimes it’s good to have boundaries. &lt;/p&gt;
&lt;p&gt;The transactions database should be accessible only to a transactions microservice. Then, if you need to scale it, it’s not so bad. Other parts of the code can interact with transactions through an abstracted API that hides the implementation details. You &lt;em&gt;could&lt;/em&gt; do this in a single application—it’s just less likely that you would. Code changes often take the path of least resistance.&lt;/p&gt;
&lt;h3 id=&quot;flexibility&quot;&gt;Flexibility&lt;a class=&quot;headerlink&quot; href=&quot;#flexibility&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Splitting your Python code into microservices gives you more flexibility. For one thing, you can write your microservices in different languages. Oftentimes, a company’s first web app will be written in &lt;a href=&quot;https://www.ruby-lang.org/en/about/&quot;&gt;Ruby&lt;/a&gt; or &lt;a href=&quot;https://www.php.net/manual/en/intro-whatis.php&quot;&gt;PHP&lt;/a&gt;. That doesn’t mean everything else has to be, too!&lt;/p&gt;
&lt;p&gt;You can also scale each microservice independently. In this tutorial, you’ll be using a web app and a Recommendations microservice as a running example. &lt;/p&gt;
&lt;p&gt;Your web app will likely be &lt;a href=&quot;https://en.wikipedia.org/wiki/I/O_bound&quot;&gt;I/O bound&lt;/a&gt;, fetching data from a database and maybe loading templates or other files from disk. A Recommendations microservice may be doing a lot of number crunching, making it &lt;a href=&quot;https://en.wikipedia.org/wiki/CPU-bound&quot;&gt;CPU bound&lt;/a&gt;. It makes sense to run these two Python microservices on different hardware.&lt;/p&gt;
&lt;h3 id=&quot;robustness&quot;&gt;Robustness&lt;a class=&quot;headerlink&quot; href=&quot;#robustness&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-microservices-grpc/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-microservices-grpc/ »&lt;/a&gt;&lt;/h2&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Modulo: Using the % Operator</title>
      <id>https://realpython.com/courses/python-modulo-operator/</id>
      <link href="https://realpython.com/courses/python-modulo-operator/"/>
      <updated>2021-02-09T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn about the Python modulo operator (%). You&#x27;ll look at the mathematical concepts behind the modulo operation and how the modulo operator is used with Python&#x27;s numeric types. You&#x27;ll also see ways to use the modulo operator in your own code.</summary>
      <content type="html">
        &lt;p&gt;Python supports a wide range of &lt;a href=&quot;https://realpython.com/python-operators-expressions/#arithmetic-operators&quot;&gt;arithmetic operators&lt;/a&gt; that you can use when working with &lt;a href=&quot;https://realpython.com/python-numbers/&quot;&gt;numbers&lt;/a&gt; in your code. One of these operators is the &lt;strong&gt;modulo operator&lt;/strong&gt; (&lt;code&gt;%&lt;/code&gt;), which returns the remainder of dividing two numbers. Modular operations are useful to check if a number is even or odd, simplifying cycling through data, and doing non-decimal based units conversion.&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 &lt;strong&gt;modulo&lt;/strong&gt; works in mathematics&lt;/li&gt;
&lt;li&gt;How to use the Python modulo operator with different &lt;strong&gt;numeric types&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How Python calculates the results of a &lt;strong&gt;modulo operation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to override &lt;strong&gt;&lt;code&gt;.__mod__()&lt;/code&gt;&lt;/strong&gt; in your classes to use them with the modulo operator&lt;/li&gt;
&lt;li&gt;How to use the Python modulo operator to solve &lt;strong&gt;real-world problems&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code in this course was tested with Python 3.9.0, &lt;code&gt;%&lt;/code&gt; has not change much and older versions should be compatible.&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 Inner Functions: What Are They Good For?</title>
      <id>https://realpython.com/inner-functions-what-are-they-good-for/</id>
      <link href="https://realpython.com/inner-functions-what-are-they-good-for/"/>
      <updated>2021-02-08T17:39:01+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll learn what inner functions are in Python, how to define them, and what their main use cases are.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;strong&gt;Inner functions&lt;/strong&gt;, also known as &lt;strong&gt;nested functions&lt;/strong&gt;, are &lt;a href=&quot;https://realpython.com/defining-your-own-python-function/&quot;&gt;functions&lt;/a&gt; that you define inside other functions. In Python, this kind of function has direct access to variables and names defined in the enclosing function. Inner functions have many uses, most notably as closure factories and decorator functions.&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;Provide &lt;strong&gt;encapsulation&lt;/strong&gt; and hide your functions from external access&lt;/li&gt;
&lt;li&gt;Write &lt;strong&gt;helper functions&lt;/strong&gt; to facilitate code reuse&lt;/li&gt;
&lt;li&gt;Create &lt;strong&gt;closure factory functions&lt;/strong&gt; that retain state between calls&lt;/li&gt;
&lt;li&gt;Code &lt;strong&gt;decorator functions&lt;/strong&gt; to add behavior to existing functions&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;&lt;p&gt;&lt;strong&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-python-cheat-sheet-shortened&quot; data-focus=&quot;false&quot;&gt;Click here to get a Python Cheat Sheet&lt;/a&gt; and learn the basics of Python 3, like working with data types, dictionaries, lists, and Python functions.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;creating-python-inner-functions&quot;&gt;Creating Python Inner Functions&lt;a class=&quot;headerlink&quot; href=&quot;#creating-python-inner-functions&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A function defined inside another function is known as an &lt;strong&gt;inner function&lt;/strong&gt; or a &lt;strong&gt;nested function&lt;/strong&gt;. In Python, this kind of function can access &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/#names-and-scopes-in-python&quot;&gt;names&lt;/a&gt; in the enclosing function. Here’s an example of how to create an inner function in Python:&lt;/p&gt;
&lt;div class=&quot;highlight python repl&quot;&gt;&lt;span class=&quot;repl-toggle&quot; title=&quot;Toggle REPL prompts and output&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;outer_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inner_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello, World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;inner_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outer_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this code, you define &lt;code&gt;inner_func()&lt;/code&gt; inside &lt;code&gt;outer_func()&lt;/code&gt; to &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;print&lt;/a&gt; the &lt;code&gt;Hello, World!&lt;/code&gt; message to the screen. To do that, you call &lt;code&gt;inner_func()&lt;/code&gt; on the last line of &lt;code&gt;outer_func()&lt;/code&gt;. This is the quickest way to write an inner function in Python. However, inner functions provide a lot of interesting possibilities beyond what you see in this example.&lt;/p&gt;
&lt;p&gt;The core feature of inner functions is their ability to access variables and objects from their enclosing function even after this function has returned. The enclosing function provides a &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;namespace&lt;/a&gt; that is accessible to the inner function:&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;outer_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;who&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inner_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;who&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;inner_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;outer_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Hello, World!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now you can pass a &lt;a href=&quot;https://realpython.com/python-strings/&quot;&gt;string&lt;/a&gt; as an argument to &lt;code&gt;outer_func()&lt;/code&gt;, and &lt;code&gt;inner_func()&lt;/code&gt; will access that argument through the name &lt;code&gt;who&lt;/code&gt;. This name, however, is defined in the &lt;a href=&quot;https://realpython.com/python-scope-legb-rule/#functions-the-local-scope&quot;&gt;local scope&lt;/a&gt; of &lt;code&gt;outer_func()&lt;/code&gt;. The names that you define in the local scope of an outer function are known as &lt;strong&gt;nonlocal names&lt;/strong&gt;. They are nonlocal from the &lt;code&gt;inner_func()&lt;/code&gt; point of view.&lt;/p&gt;
&lt;p&gt;Here’s an example of how to create and use a more elaborate inner function:&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;factorial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# Validate input&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;isinstance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;TypeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Sorry. &#x27;number&#x27; must be an integer.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&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;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;ValueError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Sorry. &#x27;number&#x27; must be zero or positive.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# Calculate the factorial of number&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inner_factorial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inner_factorial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inner_factorial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;factorial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;24&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In &lt;code&gt;factorial()&lt;/code&gt;, you first validate the input data to make sure that your user is providing an integer that is equal to or greater than zero. Then you define a recursive inner function called &lt;code&gt;inner_factorial()&lt;/code&gt; that performs the factorial calculation and &lt;a href=&quot;https://realpython.com/python-return-statement/&quot;&gt;returns&lt;/a&gt; the result. The final step is to call &lt;code&gt;inner_factorial()&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; For a more detailed discussion on recursion and recursive functions, check out &lt;a href=&quot;https://realpython.com/python-thinking-recursively/&quot;&gt;Thinking Recursively in Python&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The main advantage of using this pattern is that, by performing all the argument checking in the outer function, you can safely skip error checking in the inner function and focus on the computation at hand.&lt;/p&gt;
&lt;h2 id=&quot;using-inner-functions-the-basics&quot;&gt;Using Inner Functions: The Basics&lt;a class=&quot;headerlink&quot; href=&quot;#using-inner-functions-the-basics&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The use cases of Python inner functions are varied. You can use them to provide &lt;a href=&quot;https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)&quot;&gt;encapsulation&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Information_hiding&quot;&gt;hide&lt;/a&gt; your functions from external access, you can write helper inner functions, and you can also create &lt;a href=&quot;https://en.wikipedia.org/wiki/Closure_(computer_programming)&quot;&gt;closures&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Decorator_pattern&quot;&gt;decorators&lt;/a&gt;. In this section, you’ll learn about the former two use cases of inner functions, and in later sections, you’ll learn how to create &lt;a href=&quot;#retaining-state-with-inner-functions-closures&quot;&gt;closure factory functions&lt;/a&gt; and &lt;a href=&quot;#adding-behavior-with-inner-functions-decorators&quot;&gt;decorators&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;providing-encapsulation&quot;&gt;Providing Encapsulation&lt;a class=&quot;headerlink&quot; href=&quot;#providing-encapsulation&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A common use case of inner functions arises when you need to protect, or hide, a given function from everything happening outside of it so that the function is totally hidden from the global &lt;a href=&quot;https://realpython.com/python-namespaces-scope/&quot;&gt;scope&lt;/a&gt;. This kind of behavior is commonly known as &lt;strong&gt;encapsulation&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Here’s an example that highlights that concept:&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;increment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inner_increment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;... &lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inner_increment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;increment&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;11&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Call inner_increment()&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;inner_increment&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;input&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;n&quot;&gt;inner_increment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;gr&quot;&gt;NameError&lt;/span&gt;: &lt;span class=&quot;n&quot;&gt;name &#x27;inner_increment&#x27; is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this example, you can’t access &lt;code&gt;inner_increment()&lt;/code&gt; directly. If you try to do it, then you get a &lt;code&gt;NameError&lt;/code&gt;. That’s because &lt;code&gt;increment()&lt;/code&gt; totally hides &lt;code&gt;inner_increment()&lt;/code&gt;, preventing you from accessing it from the global scope.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/inner-functions-what-are-they-good-for/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/inner-functions-what-are-they-good-for/ »&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 #46: C for Python Developers and Data Visualization With Dash</title>
      <id>https://realpython.com/podcasts/rpp/46/</id>
      <link href="https://realpython.com/podcasts/rpp/46/"/>
      <updated>2021-02-05T12:00:00+00:00</updated>
      <summary>Are you interested in building interactive dashboards with Python? How about a project that takes a flat data file all the way to a web-hosted interactive  dashboard? This week on the show, David Amos is back, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in building interactive dashboards with Python? How about a project that takes a flat data file all the way to a web-hosted interactive  dashboard? This week on the show, David Amos is back, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Qt Designer and Python: Build Your GUI Applications Faster</title>
      <id>https://realpython.com/qt-designer-python/</id>
      <link href="https://realpython.com/qt-designer-python/"/>
      <updated>2021-02-03T14:00:00+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll learn how to use Qt Designer to create GUIs from your windows and dialogs and use them in your Python applications.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;To create a GUI for your windows and dialogs in PyQt, you can take two main paths: you can use &lt;a href=&quot;https://doc.qt.io/qt-5/qtdesigner-manual.html&quot;&gt;Qt Designer&lt;/a&gt;, or you can &lt;strong&gt;hand code&lt;/strong&gt; the GUI in plain Python code. The first path can dramatically improve your productivity, whereas the second path puts you in full control of your application’s code.&lt;/p&gt;
&lt;p&gt;GUI applications often consist of a &lt;strong&gt;main window&lt;/strong&gt; and several &lt;strong&gt;dialogs&lt;/strong&gt;. If you’re looking to create these graphical components in an efficient and user-friendly way, then Qt Designer is the tool for you. In this tutorial, you’ll learn how to use Qt Designer to create your GUIs productively.&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;Qt Designer&lt;/strong&gt; is and how to install it on your system&lt;/li&gt;
&lt;li&gt;When to use &lt;strong&gt;Qt Designer vs hand coding&lt;/strong&gt; for building your GUIs&lt;/li&gt;
&lt;li&gt;How to build and lay out the GUI of an application’s &lt;strong&gt;main window&lt;/strong&gt; using Qt Designer&lt;/li&gt;
&lt;li&gt;How to create and lay out the GUI of your &lt;strong&gt;dialogs&lt;/strong&gt; with Qt Designer&lt;/li&gt;
&lt;li&gt;How to use Qt Designer’s &lt;strong&gt;&lt;code&gt;.ui&lt;/code&gt; files&lt;/strong&gt; in your GUI applications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For a better understanding of the topics in this tutorial, you can check out the following resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&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;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-menus-toolbars/&quot;&gt;Python and PyQt: Creating Menus, Toolbars, and Status Bars&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://realpython.com/python-pyqt-layout/&quot;&gt;PyQt Layouts: Create Professional-Looking GUI Applications&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll put all this knowledge together by using the GUIs that you’ll build with Qt Designer in a sample text editor application. You can get the code and all the required resources to build this application by clicking 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/qt-designer-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-qt-designer-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 creating Python GUI applications with Qt Designer in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;getting-started-with-qt-designer&quot;&gt;Getting Started With Qt Designer&lt;a class=&quot;headerlink&quot; href=&quot;#getting-started-with-qt-designer&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Qt Designer&lt;/strong&gt; is a &lt;a href=&quot;https://www.qt.io/&quot;&gt;Qt&lt;/a&gt; tool that provides you with a &lt;a href=&quot;https://en.wikipedia.org/wiki/WYSIWYG&quot;&gt;what-you-see-is-what-you-get (WYSIWYG)&lt;/a&gt; user interface to create GUIs for your PyQt applications productively and efficiently. With this tool, you create GUIs by dragging and dropping &lt;a href=&quot;https://doc.qt.io/qt-5/qtwidgets-index.html&quot;&gt;&lt;code&gt;QWidget&lt;/code&gt;&lt;/a&gt; objects on an empty form. After that, you can arrange them into a coherent GUI using different layout managers.&lt;/p&gt;
&lt;p&gt;Qt Designer also allows you to preview your GUIs using different styles and resolutions, connect &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html&quot;&gt;signals and slots&lt;/a&gt;, create menus and toolbars, and more.&lt;/p&gt;
&lt;p&gt;Qt Designer is platform and programming language independent. It doesn’t produce code in any particular programming language, but it creates &lt;a href=&quot;https://doc.qt.io/qt-5/designer-ui-file-format.html&quot;&gt;&lt;code&gt;.ui&lt;/code&gt; files&lt;/a&gt;. These files are &lt;code&gt;XML&lt;/code&gt; files with detailed descriptions of how to generate Qt-based GUIs.&lt;/p&gt;
&lt;p&gt;You can translate the content of &lt;code&gt;.ui&lt;/code&gt; files into Python code with &lt;a href=&quot;https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html#pyuic5&quot;&gt;&lt;code&gt;pyuic5&lt;/code&gt;&lt;/a&gt;, which is a command-line tool that comes with PyQt. Then you can use this Python code in your GUI applications. You can also read &lt;code&gt;.ui&lt;/code&gt; files directly and load their content to generate the associated GUI.&lt;/p&gt;
&lt;h3 id=&quot;installing-and-running-qt-designer&quot;&gt;Installing and Running Qt Designer&lt;a class=&quot;headerlink&quot; href=&quot;#installing-and-running-qt-designer&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There are several ways to get and install Qt Designer depending on your current platform. If you use Windows or Linux, then you can run the following commands from your terminal or command line:&lt;/p&gt;
&lt;div class=&quot;highlight sh&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;python3 -m venv ./venv
&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; venv/bin/activate
&lt;span class=&quot;gp gp-VirtualEnv&quot;&gt;(venv)&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;pip install pyqt5 pyqt5-tools
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, you create a &lt;a href=&quot;https://realpython.com/python-virtual-environments-a-primer/&quot;&gt;Python virtual environment&lt;/a&gt;, activate it, and install &lt;code&gt;pyqt5&lt;/code&gt; and &lt;code&gt;pyqt5-tools&lt;/code&gt;. &lt;code&gt;pyqt5&lt;/code&gt; installs PyQt and a copy of the required Qt libraries, while &lt;code&gt;pyqt5-tools&lt;/code&gt; installs a set of Qt tools that includes Qt Designer.&lt;/p&gt;
&lt;p&gt;The installation will place the Qt Designer executable in a different directory according to your platform:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Linux:&lt;/strong&gt; &lt;code&gt;...lib/python3.x/site-packages/qt5_applications/Qt/bin/designer&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Windows:&lt;/strong&gt; &lt;code&gt;...Lib\site-packages\pyqt5_tools\designer.exe&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On Linux systems, such as Debian and Ubuntu, you can also install Qt Designer by using the system package manager 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;sudo apt install qttools5-dev-tools
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This command downloads and installs Qt Designer and other Qt tools on your system. In other words, you’ll have a system-wide installation and you’ll be able to run Qt Designer by clicking its icon in a file manager or system menu.&lt;/p&gt;
&lt;p&gt;On macOS, if you’ve installed &lt;a href=&quot;https://formulae.brew.sh/formula/qt&quot;&gt;Qt from Homebrew&lt;/a&gt; using the &lt;code&gt;brew install qt&lt;/code&gt; command, then you should have Qt Designer already installed on your system.&lt;/p&gt;
&lt;p&gt;Finally, you can download the Qt installer for your current platform from the &lt;a href=&quot;https://www.qt.io/download-qt-installer&quot;&gt;official download site&lt;/a&gt; and then follow the on-screen instructions. In this case, to complete the installation process, you need to &lt;a href=&quot;https://login.qt.io/register&quot;&gt;register a Qt account&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you’ve already installed Qt Designer using one of the options discussed so far, then go ahead and launch the application. You should get the following two windows on your screen:&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/qt-designer-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/qt-designer-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>Plot With Pandas: Python Data Visualization Basics</title>
      <id>https://realpython.com/courses/plot-pandas-data-visualization/</id>
      <link href="https://realpython.com/courses/plot-pandas-data-visualization/"/>
      <updated>2021-02-02T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll get to know the basic plotting possibilities that Python provides in the popular data analysis library pandas. You&#x27;ll learn about the different kinds of plots that pandas offers, how to use them for data exploration, and which types of plots are best for certain use cases.</summary>
      <content type="html">
        &lt;p&gt;Whether you&amp;rsquo;re just getting to know a dataset or preparing to publish your findings, &lt;strong&gt;visualization&lt;/strong&gt; is an essential tool. Python&amp;rsquo;s popular data analysis library, &lt;a href=&quot;https://pandas.pydata.org/about/&quot;&gt;pandas&lt;/a&gt;, provides several different options for visualizing your data with &lt;code&gt;.plot()&lt;/code&gt;. Even if you&amp;rsquo;re at the beginning of your pandas journey, you&amp;rsquo;ll soon be creating basic plots that will yield valuable insights into your data.&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;What the different types of &lt;strong&gt;pandas plots&lt;/strong&gt; are and when to use them&lt;/li&gt;
&lt;li&gt;How to get an overview of your dataset with a &lt;strong&gt;histogram&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to discover correlation with a &lt;strong&gt;scatter plot&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to analyze different &lt;strong&gt;categories&lt;/strong&gt; and their &lt;strong&gt;ratios&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Python Web Applications: Deploy Your Script as a Flask App</title>
      <id>https://realpython.com/python-web-applications/</id>
      <link href="https://realpython.com/python-web-applications/"/>
      <updated>2021-02-01T19:49:55+00:00</updated>
      <summary>In this tutorial, you’ll learn how to go from a local Python script to a fully deployed Flask web application that you can share with the world.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;You wrote a Python script that you’re proud of, and now you want to show it off to the world. But &lt;em&gt;how&lt;/em&gt;? Most people won’t know what to do with your &lt;code&gt;.py&lt;/code&gt; file. Converting your script into a &lt;strong&gt;Python web application&lt;/strong&gt; is a great solution to make your code usable for a broad audience.&lt;/p&gt;
&lt;p&gt;In this tutorial, you’ll learn how to go from a local Python script to a fully deployed Flask web application that you can share with the world.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;By the end of this tutorial, you’ll know:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What &lt;strong&gt;web applications&lt;/strong&gt; are and how you can &lt;strong&gt;host&lt;/strong&gt; them online&lt;/li&gt;
&lt;li&gt;How to convert a Python script into a &lt;strong&gt;Flask web application&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to improve user experience by &lt;strong&gt;adding HTML&lt;/strong&gt; to your Python code&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;deploy&lt;/strong&gt; your Python web application to &lt;strong&gt;Google App Engine&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition to walking through an example project, you’ll find a number of &lt;strong&gt;exercises&lt;/strong&gt; throughout the tutorial. They’ll give you a chance to solidify what you’re learning through extra practice. You can also download the source code that you’ll use to build your web application by clicking 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 Sample Code:&lt;/strong&gt; &lt;a href=&quot;https://realpython.com/bonus/python-web-apps-code/&quot; class=&quot;alert-link&quot; data-toggle=&quot;modal&quot; data-target=&quot;#modal-python-web-apps-code&quot; data-focus=&quot;false&quot; markdown=&quot;1&quot;&gt;Click here to get the sample code you’ll use&lt;/a&gt; to learn about creating Python web applications with Flask in this tutorial.&lt;/p&gt;
&lt;/div&gt;
&lt;h2 id=&quot;brush-up-on-the-basics&quot;&gt;Brush Up on the Basics&lt;a class=&quot;headerlink&quot; href=&quot;#brush-up-on-the-basics&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this section, you’ll get a theoretical footing in the different topics that you’ll work with during the practical part of this tutorial:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What types of Python code distribution exist&lt;/li&gt;
&lt;li&gt;Why building a web application can be a good choice&lt;/li&gt;
&lt;li&gt;What a web application is&lt;/li&gt;
&lt;li&gt;How content gets delivered over the Internet&lt;/li&gt;
&lt;li&gt;What web hosting means&lt;/li&gt;
&lt;li&gt;Which hosting providers exist and which one to use&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Brushing up on these topics can help you feel more confident when writing Python code for the Web. However, if you’re already familiar with them, then feel free to skip ahead, &lt;a href=&quot;#choose-a-hosting-provider-google-app-engine&quot;&gt;install the Google Cloud SDK&lt;/a&gt;, and start building your Python web app.&lt;/p&gt;
&lt;h3 id=&quot;distribute-your-python-code&quot;&gt;Distribute Your Python Code&lt;a class=&quot;headerlink&quot; href=&quot;#distribute-your-python-code&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Bringing your code to your users is called &lt;strong&gt;distribution&lt;/strong&gt;. Traditionally, there are three different approaches you can use to distribute your code so that others can work with your programs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Python library&lt;/li&gt;
&lt;li&gt;Standalone program&lt;/li&gt;
&lt;li&gt;Python web application&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You’ll take a closer look at each of these approaches below.&lt;/p&gt;
&lt;h4 id=&quot;python-library&quot;&gt;Python Library&lt;a class=&quot;headerlink&quot; href=&quot;#python-library&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;If you’ve worked with Python’s extensive package ecosystem, then you’ve likely installed &lt;a href=&quot;https://realpython.com/python-modules-packages/&quot;&gt;Python packages&lt;/a&gt; with &lt;a href=&quot;https://realpython.com/what-is-pip/&quot;&gt;&lt;code&gt;pip&lt;/code&gt;&lt;/a&gt;. As a programmer, you might want to &lt;a href=&quot;https://realpython.com/pypi-publish-python-package/&quot;&gt;publish your Python package on PyPI&lt;/a&gt; to allow other users to access and use your code by installing it using &lt;code&gt;pip&lt;/code&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;python3 -m pip install &amp;lt;your-package-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After you’ve successfully published your code to PyPI, this command will install your package, including its dependencies, on any of your users’ computers, provided that they have an Internet connection.&lt;/p&gt;
&lt;p&gt;If you don’t want to publish your code as a PyPI package, then you can still use Python’s built-in &lt;code&gt;sdist&lt;/code&gt; command to create a &lt;a href=&quot;https://docs.python.org/3/distutils/sourcedist.html&quot;&gt;source distribution&lt;/a&gt; or a &lt;a href=&quot;https://realpython.com/python-wheels/&quot;&gt;Python wheel&lt;/a&gt; to create a &lt;a href=&quot;https://packaging.python.org/glossary/#term-built-distribution&quot;&gt;built distribution&lt;/a&gt; to share with your users.&lt;/p&gt;
&lt;p&gt;Distributing your code like this keeps it close to the original script you wrote and adds only what’s necessary for others to run it. However, using this approach also means that your users will need to run your code with Python. Many people who want to use your script’s functionality won’t have Python installed or won’t be familiar with the processes required to work directly with your code.&lt;/p&gt;
&lt;p&gt;A more user-friendly way to present your code to potential users is to build a standalone program.&lt;/p&gt;
&lt;h4 id=&quot;standalone-program&quot;&gt;Standalone Program&lt;a class=&quot;headerlink&quot; href=&quot;#standalone-program&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Computer programs come in different shapes and forms, and there are multiple options for transforming your Python scripts into standalone programs. Below you’ll read about two possibilities:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Packaging your code&lt;/li&gt;
&lt;li&gt;Building a GUI&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Programs such as &lt;a href=&quot;https://www.pyinstaller.org/&quot;&gt;PyInstaller&lt;/a&gt;, &lt;a href=&quot;https://py2app.readthedocs.io/en/latest/&quot;&gt;py2app&lt;/a&gt;, &lt;a href=&quot;https://www.py2exe.org/&quot;&gt;py2exe&lt;/a&gt;, or &lt;a href=&quot;https://briefcase.readthedocs.io/en/latest/&quot;&gt;Briefcase&lt;/a&gt; can help with packaging your code. They turn Python scripts into executable programs that can be used on different platforms without requiring your users to explicitly run the Python interpreter.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-web-applications/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-web-applications/ »&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 #45: Processing Images in Python With Pillow</title>
      <id>https://realpython.com/podcasts/rpp/45/</id>
      <link href="https://realpython.com/podcasts/rpp/45/"/>
      <updated>2021-01-29T12:00:00+00:00</updated>
      <summary>Are you interested in processing images in Python? Do you need to load and modify images for your Flask or Django website or CMS? Then you most likely will be working with Pillow, the friendly fork of PIL, the Python imaging library. This week on the show, we have Mike Driscoll, who is writing a new book about image processing in Python.</summary>
      <content type="html">
        &lt;p&gt;Are you interested in processing images in Python? Do you need to load and modify images for your Flask or Django website or CMS? Then you most likely will be working with Pillow, the friendly fork of PIL, the Python imaging library. This week on the show, we have Mike Driscoll, who is writing a new book about image processing in Python.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Stochastic Gradient Descent Algorithm With Python and NumPy</title>
      <id>https://realpython.com/gradient-descent-algorithm-python/</id>
      <link href="https://realpython.com/gradient-descent-algorithm-python/"/>
      <updated>2021-01-27T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn what the stochastic gradient descent algorithm is, how it works, and how to implement it with Python and NumPy.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Stochastic_gradient_descent&quot;&gt;&lt;strong&gt;Stochastic gradient descent&lt;/strong&gt;&lt;/a&gt; is an optimization algorithm often used in machine learning applications to find the model parameters that correspond to the best fit between predicted and actual outputs. It’s an inexact but powerful technique.&lt;/p&gt;
&lt;p&gt;Stochastic gradient descent is widely used in machine learning applications. Combined with &lt;a href=&quot;https://brilliant.org/wiki/backpropagation/&quot;&gt;backpropagation&lt;/a&gt;, it’s dominant in &lt;a href=&quot;https://realpython.com/python-keras-text-classification/#a-primer-on-deep-neural-networks&quot;&gt;neural network&lt;/a&gt; training applications.&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 &lt;strong&gt;gradient descent&lt;/strong&gt; and &lt;strong&gt;stochastic gradient descent&lt;/strong&gt; algorithms work&lt;/li&gt;
&lt;li&gt;How to apply gradient descent and stochastic gradient descent to &lt;strong&gt;minimize the loss function&lt;/strong&gt; in machine learning&lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;learning rate&lt;/strong&gt; is, why it’s important, and how it impacts results&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;write your own function&lt;/strong&gt; for stochastic gradient descent&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&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;basic-gradient-descent-algorithm&quot;&gt;Basic Gradient Descent Algorithm&lt;a class=&quot;headerlink&quot; href=&quot;#basic-gradient-descent-algorithm&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Gradient_descent&quot;&gt;gradient descent algorithm&lt;/a&gt; is an approximate and iterative method for &lt;a href=&quot;https://en.wikipedia.org/wiki/Mathematical_optimization&quot;&gt;mathematical optimization&lt;/a&gt;. You can use it to approach the minimum of any &lt;a href=&quot;https://en.wikipedia.org/wiki/Differentiable_function&quot;&gt;differentiable function&lt;/a&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; There are many optimization methods and &lt;a href=&quot;https://en.wikipedia.org/wiki/Mathematical_optimization#Major_subfields&quot;&gt;subfields of mathematical programming&lt;/a&gt;. If you want to learn how to use some of them with Python, then check out &lt;a href=&quot;https://realpython.com/python-scipy-cluster-optimize/&quot;&gt;Scientific Python: Using SciPy for Optimization&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/linear-programming-python/&quot;&gt;Hands-On Linear Programming: Optimization With Python&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Although gradient descent sometimes gets stuck in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Local_optimum&quot;&gt;local minimum&lt;/a&gt; or a &lt;a href=&quot;https://en.wikipedia.org/wiki/Saddle_point&quot;&gt;saddle point&lt;/a&gt; instead of finding the global minimum, it’s widely used in practice. &lt;a href=&quot;https://realpython.com/learning-paths/data-science-python-core-skills/&quot;&gt;Data science&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/learning-paths/machine-learning-python/&quot;&gt;machine learning&lt;/a&gt; methods often apply it internally to optimize model parameters. For example, neural networks find &lt;a href=&quot;https://docs.paperspace.com/machine-learning/wiki/weights-and-biases&quot;&gt;weights and biases&lt;/a&gt; with gradient descent.&lt;/p&gt;
&lt;h3 id=&quot;cost-function-the-goal-of-optimization&quot;&gt;Cost Function: The Goal of Optimization&lt;a class=&quot;headerlink&quot; href=&quot;#cost-function-the-goal-of-optimization&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;cost function&lt;/strong&gt;, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Loss_function&quot;&gt;loss function&lt;/a&gt;, is the function to be minimized (or maximized) by varying the decision variables. Many machine learning methods solve optimization problems under the surface. They tend to minimize the difference between actual and predicted outputs by adjusting the model parameters (like weights and biases for &lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_neural_network&quot;&gt;neural networks&lt;/a&gt;, decision rules for &lt;a href=&quot;https://en.wikipedia.org/wiki/Random_forest&quot;&gt;random forest&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Gradient_boosting&quot;&gt;gradient boosting&lt;/a&gt;, and so on).&lt;/p&gt;
&lt;p&gt;In a &lt;a href=&quot;https://realpython.com/linear-regression-in-python/#regression&quot;&gt;regression problem&lt;/a&gt;, you typically have the vectors of input variables 𝐱 = (𝑥₁, …, 𝑥ᵣ) and the actual outputs 𝑦. You want to find a model that maps 𝐱 to a predicted response 𝑓(𝐱) so that 𝑓(𝐱) is as close as possible to 𝑦. For example, you might want to predict an output such as a person’s salary given inputs like the person’s number of years at the company or level of education.&lt;/p&gt;
&lt;p&gt;Your goal is to minimize the difference between the prediction 𝑓(𝐱) and the actual data 𝑦. This difference is called the &lt;strong&gt;residual&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In this type of problem, you want to minimize the &lt;a href=&quot;https://en.wikipedia.org/wiki/Residual_sum_of_squares&quot;&gt;sum of squared residuals (SSR)&lt;/a&gt;, where SSR = Σᵢ(𝑦ᵢ − 𝑓(𝐱ᵢ))² for all observations 𝑖 = 1, …, 𝑛, where 𝑛 is the total number of observations. Alternatively, you could use the &lt;a href=&quot;https://en.wikipedia.org/wiki/Mean_squared_error&quot;&gt;mean squared error&lt;/a&gt; (MSE = SSR / 𝑛) instead of SSR.&lt;/p&gt;
&lt;p&gt;Both SSR and MSE use the square of the difference between the actual and predicted outputs. The lower the difference, the more accurate the prediction. A difference of zero indicates that the prediction is equal to the actual data.&lt;/p&gt;
&lt;p&gt;SSR or MSE is minimized by adjusting the model parameters. For example, in &lt;a href=&quot;https://realpython.com/linear-regression-in-python/&quot;&gt;linear regression&lt;/a&gt;, you want to find the function 𝑓(𝐱) = 𝑏₀ + 𝑏₁𝑥₁ + ⋯ + 𝑏ᵣ𝑥ᵣ, so you need to determine the weights 𝑏₀, 𝑏₁, …, 𝑏ᵣ that minimize SSR or MSE.&lt;/p&gt;
&lt;p&gt;In a &lt;a href=&quot;https://realpython.com/logistic-regression-python/#classification&quot;&gt;classification problem&lt;/a&gt;, the outputs 𝑦 are &lt;a href=&quot;https://en.wikipedia.org/wiki/Categorical_variable&quot;&gt;categorical&lt;/a&gt;, often either 0 or 1. For example, you might try to predict whether an email is spam or not. In the case of binary outputs, it’s convenient to minimize the &lt;a href=&quot;https://en.wikipedia.org/wiki/Cross_entropy&quot;&gt;cross-entropy function&lt;/a&gt; that also depends on the actual outputs 𝑦ᵢ and the corresponding predictions 𝑝(𝐱ᵢ):&lt;/p&gt;
&lt;figure&gt;&lt;a href=&quot;https://files.realpython.com/media/mmst-gda-eqs-1.119ab87cc186.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block w-66&quot; src=&quot;https://files.realpython.com/media/mmst-gda-eqs-1.119ab87cc186.png&quot; width=&quot;1816&quot; height=&quot;194&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/mmst-gda-eqs-1.119ab87cc186.png&amp;amp;w=454&amp;amp;sig=e6d8b3e4d147738a8c0ccebf2e4747b5b63b74a9 454w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/mmst-gda-eqs-1.119ab87cc186.png&amp;amp;w=908&amp;amp;sig=1558fcfcdbaf30b23a55ae380291769b090d1194 908w, https://files.realpython.com/media/mmst-gda-eqs-1.119ab87cc186.png 1816w&quot; sizes=&quot;75vw&quot; alt=&quot;mmst-gda-eqs-1&quot; data-asset=&quot;3400&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;In &lt;a href=&quot;https://realpython.com/logistic-regression-python/&quot;&gt;logistic regression&lt;/a&gt;, which is often used to solve classification problems, the functions 𝑝(𝐱) and 𝑓(𝐱) are defined as the following:&lt;/p&gt;
&lt;figure&gt;&lt;a href=&quot;https://files.realpython.com/media/mmst-gda-eqs-2.76aa15da2cc0.png&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid mx-auto d-block w-66&quot; src=&quot;https://files.realpython.com/media/mmst-gda-eqs-2.76aa15da2cc0.png&quot; width=&quot;1820&quot; height=&quot;317&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/mmst-gda-eqs-2.76aa15da2cc0.png&amp;amp;w=455&amp;amp;sig=8d933a1259c626545ac1760d9fdbb509c1efe61e 455w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/mmst-gda-eqs-2.76aa15da2cc0.png&amp;amp;w=910&amp;amp;sig=c961e1c3c89347d7084083609cb267b54dfb67be 910w, https://files.realpython.com/media/mmst-gda-eqs-2.76aa15da2cc0.png 1820w&quot; sizes=&quot;75vw&quot; alt=&quot;mmst-gda-eqs-2&quot; data-asset=&quot;3401&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Again, you need to find the weights 𝑏₀, 𝑏₁, …, 𝑏ᵣ, but this time they should minimize the cross-entropy function.&lt;/p&gt;
&lt;h3 id=&quot;gradient-of-a-function-calculus-refresher&quot;&gt;Gradient of a Function: Calculus Refresher&lt;a class=&quot;headerlink&quot; href=&quot;#gradient-of-a-function-calculus-refresher&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In calculus, the &lt;a href=&quot;https://www.mathsisfun.com/calculus/derivatives-introduction.html&quot;&gt;derivative&lt;/a&gt; of a function shows you how much a value changes when you modify its argument (or arguments). Derivatives are important for optimization because the &lt;a href=&quot;http://sofia.nmsu.edu/~breakingaway/ebookofcalculus/MeaningOfDerivativesAndIntegrals/WhatDoesItMeanThatTheDerivativeOfAFunctionEquals0/WhatDoesItMeanThatTheDerivativeOfAFunctionEquals0.html&quot;&gt;zero derivatives&lt;/a&gt; might indicate a minimum, maximum, or saddle point.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Gradient&quot;&gt;gradient&lt;/a&gt; of a function 𝐶 of several independent variables 𝑣₁, …, 𝑣ᵣ is denoted with ∇𝐶(𝑣₁, …, 𝑣ᵣ) and defined as the vector function of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Partial_derivative&quot;&gt;partial derivatives&lt;/a&gt; of 𝐶 with respect to each independent variable: ∇𝐶 = (∂𝐶/∂𝑣₁, …, ∂𝐶/𝑣ᵣ). The symbol ∇ is called &lt;a href=&quot;https://en.wikipedia.org/wiki/Nabla_symbol&quot;&gt;nabla&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The nonzero value of the gradient of a function 𝐶 at a given point defines the direction and rate of the fastest increase of 𝐶. When working with gradient descent, you’re interested in the direction of the fastest &lt;em&gt;decrease&lt;/em&gt; in the cost function. This direction is determined by the negative gradient, −∇𝐶.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/gradient-descent-algorithm-python/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/gradient-descent-algorithm-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>Evaluate Expressions Dynamically With Python eval()</title>
      <id>https://realpython.com/courses/evaluate-expressions-dynamically-python-eval/</id>
      <link href="https://realpython.com/courses/evaluate-expressions-dynamically-python-eval/"/>
      <updated>2021-01-26T14:00:00+00:00</updated>
      <summary>In this step-by-step course, you&#x27;ll learn how Python&#x27;s eval() works and how to use it effectively in your programs. Additionally, you&#x27;ll learn how to minimize the security risks associated to the use of eval().</summary>
      <content type="html">
        &lt;p&gt;The built-in Python function &lt;code&gt;eval()&lt;/code&gt; is used to evaluate Python expressions. You can pass a string containing Python, or a pre-compiled object into &lt;code&gt;eval()&lt;/code&gt; and it will run the code and return the result. &lt;/p&gt;
&lt;p&gt;Although Python&amp;rsquo;s &lt;code&gt;eval()&lt;/code&gt; is an incredibly useful tool, the function has some important security implications that you should consider before using it. In this course, you&amp;rsquo;ll learn how &lt;code&gt;eval()&lt;/code&gt; works and how to use it safely and effectively in your Python programs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you&amp;rsquo;ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How Python&amp;rsquo;s &lt;strong&gt;&lt;code&gt;eval()&lt;/code&gt;&lt;/strong&gt; works&lt;/li&gt;
&lt;li&gt;How to use &lt;code&gt;eval()&lt;/code&gt; to &lt;strong&gt;dynamically evaluate&lt;/strong&gt; arbitrary string-based or compiled-code-based input&lt;/li&gt;
&lt;li&gt;How &lt;code&gt;eval()&lt;/code&gt; can make your code insecure and how to minimize the associated &lt;strong&gt;security risks&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code in this course was tested with Python 3.9.0, &lt;code&gt;eval()&lt;/code&gt; has not changed much and older versions should be compatible.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>How to Use Python: Your First Steps</title>
      <id>https://realpython.com/python-first-steps/</id>
      <link href="https://realpython.com/python-first-steps/"/>
      <updated>2021-01-25T16:27:13+00:00</updated>
      <summary>In this step-by-step tutorial, you&#x27;ll learn the basics of how to use Python. With this knowledge, you&#x27;ll be able to start coding your Python applications.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Are you looking for a place to learn the basics of how to use &lt;a href=&quot;https://realpython.com/learning-paths/python3-introduction/&quot;&gt;Python from a beginner’s perspective&lt;/a&gt;? Do you want to get up and running with Python but don’t know where to start? If so, then this tutorial is for you. This tutorial focuses on the essentials you need to know to start programming with Python.&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;Python&lt;/strong&gt; is and why you should use it&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;basic Python syntax&lt;/strong&gt; you should learn to start coding&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;handle errors&lt;/strong&gt; in Python&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;get help&lt;/strong&gt; quickly in Python&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;code style&lt;/strong&gt; you should apply in your code&lt;/li&gt;
&lt;li&gt;Where to get &lt;strong&gt;extra functionalities&lt;/strong&gt; without reinventing the wheel&lt;/li&gt;
&lt;li&gt;Where to find quality Python content and &lt;strong&gt;grow your skills&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’ll also have the opportunity to create your first Python program and &lt;a href=&quot;https://realpython.com/run-python-scripts/&quot;&gt;run it on your computer&lt;/a&gt;. Finally, you’ll have a chance to evaluate your progress with a quiz that’ll give you an idea of how much you’ve learned.&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-python-cheat-sheet-experiment&quot; data-focus=&quot;false&quot;&gt;Click here to get our free Python Cheat Sheet&lt;/a&gt; that shows you the basics of Python 3, like working with data types, dictionaries, lists, and Python functions.&lt;/p&gt;&lt;/div&gt;

&lt;h2 id=&quot;why-you-should-use-python&quot;&gt;Why You Should Use Python&lt;a class=&quot;headerlink&quot; href=&quot;#why-you-should-use-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure&gt;&lt;a href=&quot;https://files.realpython.com/media/pythonlogo.0658b34b4498.jpg&quot; target=&quot;_blank&quot;&gt;&lt;img loading=&quot;lazy&quot; class=&quot;img-fluid w-25 float-right&quot; src=&quot;https://files.realpython.com/media/pythonlogo.0658b34b4498.jpg&quot; width=&quot;680&quot; height=&quot;459&quot; srcset=&quot;https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pythonlogo.0658b34b4498.jpg&amp;amp;w=170&amp;amp;sig=ac227e7d70841aa87fe92a62acbdddf6938350eb 170w, https://robocrop.realpython.net/?url=https%3A//files.realpython.com/media/pythonlogo.0658b34b4498.jpg&amp;amp;w=340&amp;amp;sig=1afd2a88fd379da035a4734b3e5d8616075dcf22 340w, https://files.realpython.com/media/pythonlogo.0658b34b4498.jpg 680w&quot; sizes=&quot;75vw&quot; alt=&quot;The Python Logo. The Python logo is a trademark of the Python Software Foundation.&quot; data-asset=&quot;183&quot;&gt;&lt;/a&gt;&lt;/figure&gt;

&lt;p&gt;Python, named after the British comedy group &lt;a href=&quot;https://en.wikipedia.org/wiki/Monty_Python&quot;&gt;Monty Python&lt;/a&gt;, is a &lt;strong&gt;high-level&lt;/strong&gt;, &lt;strong&gt;interpreted&lt;/strong&gt;, &lt;strong&gt;interactive&lt;/strong&gt;, and &lt;strong&gt;object-oriented&lt;/strong&gt; programming language. Its flexibility allows you to do &lt;a href=&quot;https://realpython.com/what-can-i-do-with-python/&quot;&gt;many things&lt;/a&gt;, both big and small. With Python, you can write basic programs and scripts and also to create complex and large-scale enterprise solutions. Here’s a sampling of its uses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Building desktop applications, including &lt;a href=&quot;https://realpython.com/learning-paths/python-gui-programming/&quot;&gt;GUI applications&lt;/a&gt;, &lt;a href=&quot;https://realpython.com/command-line-interfaces-python-argparse/&quot;&gt;CLI tools&lt;/a&gt;, and even &lt;a href=&quot;https://realpython.com/pygame-a-primer/&quot;&gt;games&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Doing &lt;a href=&quot;https://realpython.com/learning-paths/math-data-science/&quot;&gt;mathematical&lt;/a&gt; and &lt;a href=&quot;https://realpython.com/learning-paths/data-science-python-core-skills/&quot;&gt;scientific&lt;/a&gt; analysis of data&lt;/li&gt;
&lt;li&gt;Building &lt;a href=&quot;https://realpython.com/learning-paths/become-python-web-developer/&quot;&gt;web&lt;/a&gt; and Internet applications&lt;/li&gt;
&lt;li&gt;Doing computer systems administration and automating tasks&lt;/li&gt;
&lt;li&gt;Performing &lt;a href=&quot;https://realpython.com/tutorials/devops/&quot;&gt;DevOps&lt;/a&gt; tasks&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can find Python everywhere in the world of computer programming. For example, Python is the foundation of some of the world’s &lt;a href=&quot;https://realpython.com/world-class-companies-using-python/&quot;&gt;most popular websites&lt;/a&gt;, including Reddit, Dropbox, and YouTube, to name a few. The Python web framework &lt;a href=&quot;https://realpython.com/learning-paths/django-web-development/&quot;&gt;Django&lt;/a&gt; powers both &lt;a href=&quot;https://www.instagram.com/&quot;&gt;Instagram&lt;/a&gt; and &lt;a href=&quot;https://pinterest.com/&quot;&gt;Pinterest&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Python has a bunch of features that make it attractive as your first programming language:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Free:&lt;/strong&gt; Python is available free of charge, even for commercial purposes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open source:&lt;/strong&gt; Anyone can contribute to Python development.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accessible:&lt;/strong&gt; People of all ages, from school children to retirees, have learned Python, and so can you.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Versatile:&lt;/strong&gt; Python can help you solve problems in many fields, including scripting, data science, web development, GUI development, and more.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Powerful:&lt;/strong&gt; You can code small scripts to automate repetitive tasks, and you can also create complex and large-scale enterprise solutions with Python.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Compared to other programming languages, Python has the following features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Interpreted:&lt;/strong&gt; It’s portable and quicker to experiment with than compiled languages.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiparadigm:&lt;/strong&gt; It lets you write code in different styles, including &lt;a href=&quot;https://realpython.com/python3-object-oriented-programming/&quot;&gt;object-oriented&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Imperative_programming&quot;&gt;imperative&lt;/a&gt;, and &lt;a href=&quot;https://realpython.com/python-reduce-function/&quot;&gt;functional&lt;/a&gt; style.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamically typed:&lt;/strong&gt; It checks &lt;a href=&quot;https://realpython.com/python-variables/&quot;&gt;variable&lt;/a&gt; types at runtime, so you don’t need to declare them explicitly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Strongly typed:&lt;/strong&gt; It won’t let unsafe operations on incompatible types go unnoticed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There’s a lot more to learn about Python. But by now, you should have a better idea of why Python is so popular and why you should consider learning to program with it.&lt;/p&gt;
&lt;h2 id=&quot;how-to-download-and-install-python&quot;&gt;How to Download and Install Python&lt;a class=&quot;headerlink&quot; href=&quot;#how-to-download-and-install-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python works on Linux, Mac, Windows, and several other platforms. It comes preinstalled on macOS and on most Linux distributions. However, if you want to be up to date, then you probably need to download and install the latest version. You also have the choice of using &lt;a href=&quot;https://realpython.com/intro-to-pyenv/&quot;&gt;different Python versions&lt;/a&gt; in different projects if you want to.&lt;/p&gt;
&lt;p&gt;To check what Python version has been installed globally in your operating system, open the terminal or command line and run 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;python3 -V
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This command prints the version of your system’s default Python 3 installation. Note that you use &lt;code&gt;python3&lt;/code&gt; instead of &lt;code&gt;python&lt;/code&gt; because some operating systems still include Python 2 as their default Python installation.&lt;/p&gt;
&lt;h3 id=&quot;installing-python-from-binaries&quot;&gt;Installing Python From Binaries&lt;a class=&quot;headerlink&quot; href=&quot;#installing-python-from-binaries&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Regardless of your operating system, you can download an appropriate version of Python from the &lt;a href=&quot;https://www.python.org/&quot;&gt;official site&lt;/a&gt;. Go there and grab the appropriate 32-bit or 64-bit version for your operating system and processor.&lt;/p&gt;
&lt;p&gt;Selecting and downloading a Python binary from the language’s official site is often a good choice. However, there are some OS-specific alternatives:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;macOS:&lt;/strong&gt; You have the option of &lt;a href=&quot;https://realpython.com/installing-python/#what-your-options-are_1&quot;&gt;installing Python&lt;/a&gt; from &lt;a href=&quot;http://brew.sh/&quot;&gt;Homebrew&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linux:&lt;/strong&gt; You can install several Python versions using your distribution’s package manager.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Windows:&lt;/strong&gt; You can install Python from the &lt;a href=&quot;https://www.microsoft.com/en-ca/search?q=python&quot;&gt;Microsoft Store&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also use the &lt;a href=&quot;https://www.anaconda.com/products/individual&quot;&gt;Anaconda distribution&lt;/a&gt; to install Python along with a rich set of packages and libraries, or you can use &lt;a href=&quot;https://docs.conda.io/en/latest/miniconda.html&quot;&gt;Miniconda&lt;/a&gt; if you want to install only the packages you need.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/python-first-steps/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-first-steps/ »&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 #44: Creating an Interactive Online Python Conference for PyCascades 2021</title>
      <id>https://realpython.com/podcasts/rpp/44/</id>
      <link href="https://realpython.com/podcasts/rpp/44/"/>
      <updated>2021-01-22T12:00:00+00:00</updated>
      <summary>How do you create a virtual conference that retains the interactivity of an in-person event? What are the tools needed for talk submissions, ticketing, and live hosting? Can you find those tools written in Python? 
This week on the show, we have several of the organizers of the PyCascades 2021 conference. They share the process of restructuring a Python conference to meet those challenges.</summary>
      <content type="html">
        &lt;p&gt;How do you create a virtual conference that retains the interactivity of an in-person event? What are the tools needed for talk submissions, ticketing, and live hosting? Can you find those tools written in Python? 
This week on the show, we have several of the organizers of the PyCascades 2021 conference. They share the process of restructuring a Python conference to meet those challenges.&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>C for Python Programmers</title>
      <id>https://realpython.com/c-for-python-programmers/</id>
      <link href="https://realpython.com/c-for-python-programmers/"/>
      <updated>2021-01-20T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn the basics of the C language, which is used in the source code for CPython, the most popular Python implementation. Learning C is important for Python programmers interested in contributing to CPython.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;The purpose of this tutorial is to get an experienced Python programmer up to speed with the basics of the &lt;a href=&quot;https://en.wikipedia.org/wiki/C_(programming_language)&quot;&gt;C language&lt;/a&gt; and how it’s used in the &lt;a href=&quot;https://en.wikipedia.org/wiki/CPython&quot;&gt;CPython&lt;/a&gt; source code. It assumes you already have an intermediate understanding of Python syntax.&lt;/p&gt;
&lt;p&gt;That said, C is a fairly limited language, and most of its usage in CPython falls under a small set of syntax rules. Getting to the point where you understand the code is a much smaller step than being able to write C effectively. This tutorial is aimed at the first goal but not the second.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll learn:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What the &lt;strong&gt;C preprocessor&lt;/strong&gt; is and what role it plays in building C programs&lt;/li&gt;
&lt;li&gt;How you can use &lt;strong&gt;preprocessor directives&lt;/strong&gt; to manipulate source files&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;C syntax&lt;/strong&gt; compares to &lt;strong&gt;Python syntax&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;How to create &lt;strong&gt;loops&lt;/strong&gt;, &lt;strong&gt;functions&lt;/strong&gt;, &lt;strong&gt;strings&lt;/strong&gt;, and other features in C&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One of the first things that stands out as a big difference between Python and C is the C preprocessor. You’ll look at that first.&lt;/p&gt;
&lt;div class=&quot;alert alert-primary&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This tutorial is adapted from the appendix, “Introduction to C for Python Programmers,” in &lt;a href=&quot;https://realpython.com/products/cpython-internals-book/&quot;&gt;&lt;em&gt;CPython Internals: Your Guide to the Python Interpreter&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&quot;1&quot;&gt;Free 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;the-c-preprocessor&quot;&gt;The C Preprocessor&lt;a class=&quot;headerlink&quot; href=&quot;#the-c-preprocessor&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The preprocessor, as the name suggests, is run on your source files before the compiler runs. It has very limited abilities, but you can use them to great advantage in building C programs.&lt;/p&gt;
&lt;p&gt;The preprocessor produces a new file, which is what the compiler will actually process. All the commands to the preprocessor start at the beginning of a line, with a &lt;code&gt;#&lt;/code&gt; symbol as the first non-whitespace character.&lt;/p&gt;
&lt;p&gt;The main purpose of the preprocessor is to do text substitution in the source file, but it will also do some basic conditional code with &lt;code&gt;#if&lt;/code&gt; or similar statements.&lt;/p&gt;
&lt;p&gt;You’ll start with the most frequent preprocessor directive: &lt;code&gt;#include&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;include&quot;&gt;&lt;code&gt;#include&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#include&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;#include&lt;/code&gt; is used to pull the contents of one file into the current source file. There’s nothing sophisticated about &lt;code&gt;#include&lt;/code&gt;. It reads a file from the file system, runs the preprocessor on that file, and puts the results into the output file. This is done recursively for each &lt;code&gt;#include&lt;/code&gt; directive.&lt;/p&gt;
&lt;p&gt;For example, if you look at CPython’s &lt;a href=&quot;https://github.com/python/cpython/blob/master/Modules/_multiprocessing/semaphore.c&quot;&gt;&lt;code&gt;Modules/_multiprocessing/semaphore.c&lt;/code&gt; file&lt;/a&gt;, then near the top you’ll see the following line:&lt;/p&gt;
&lt;div class=&quot;highlight c&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&quot;multiprocessing.h&quot;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This tells the preprocessor to pull in the entire contents of &lt;code&gt;multiprocessing.h&lt;/code&gt; and put them into the output file at this position.&lt;/p&gt;
&lt;p&gt;You’ll notice two different forms for the &lt;code&gt;#include&lt;/code&gt; statement. One of them uses quotes (&lt;code&gt;&quot;&quot;&lt;/code&gt;) to specify the name of the include file, and the other uses angle brackets (&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;). The difference comes from which paths are searched when looking for the file on the file system.&lt;/p&gt;
&lt;p&gt;If you use &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; for the filename, then the preprocessor will look only at system include files. Using quotes around the filename instead will force the preprocessor to look in the local directory first and then fall back to the system directories.&lt;/p&gt;
&lt;h3 id=&quot;define&quot;&gt;&lt;code&gt;#define&lt;/code&gt;&lt;a class=&quot;headerlink&quot; href=&quot;#define&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;#define&lt;/code&gt; allows you to do simple text substitution and also plays into the &lt;code&gt;#if&lt;/code&gt; directives you’ll see below.&lt;/p&gt;
&lt;p&gt;At its most basic, &lt;code&gt;#define&lt;/code&gt; lets you define a new symbol that gets replaced with a text string in the preprocessor output.&lt;/p&gt;
&lt;p&gt;Continuing in &lt;code&gt;semphore.c&lt;/code&gt;, you’ll find this line:&lt;/p&gt;
&lt;div class=&quot;highlight c&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#define SEM_FAILED NULL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This tells the preprocessor to replace every instance of &lt;code&gt;SEM_FAILED&lt;/code&gt; below this point with the literal string &lt;code&gt;NULL&lt;/code&gt; before the code is sent to the compiler.&lt;/p&gt;
&lt;/div&gt;&lt;h2&gt;&lt;a href=&quot;https://realpython.com/c-for-python-programmers/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/c-for-python-programmers/ »&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>Introduction to Sorting Algorithms in Python</title>
      <id>https://realpython.com/courses/intro-sorting-algorithms/</id>
      <link href="https://realpython.com/courses/intro-sorting-algorithms/"/>
      <updated>2021-01-19T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn all about five different sorting algorithms in Python from both a theoretical and a practical standpoint. You&#x27;ll also learn several related and important concepts, including Big O notation and recursion.</summary>
      <content type="html">
        &lt;p&gt;&lt;strong&gt;Sorting&lt;/strong&gt; is a basic building block that many other algorithms are built upon. It&amp;rsquo;s related to several exciting ideas that you&amp;rsquo;ll see throughout your programming career. Understanding how sorting algorithms in Python work behind the scenes is a fundamental step toward implementing correct and efficient algorithms that solve real-world problems.&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 different &lt;strong&gt;sorting algorithms in Python&lt;/strong&gt; work and how they compare under different circumstances&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;Python&amp;rsquo;s built-in sort functionality&lt;/strong&gt; works behind the scenes&lt;/li&gt;
&lt;li&gt;How different computer science concepts like &lt;strong&gt;recursion&lt;/strong&gt; and &lt;strong&gt;divide and conquer&lt;/strong&gt; apply to sorting&lt;/li&gt;
&lt;li&gt;What &lt;strong&gt;Big O notation&lt;/strong&gt; is and how to use it to compare the efficiency of different 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>Make Your First Python Game: Rock, Paper, Scissors!</title>
      <id>https://realpython.com/python-rock-paper-scissors/</id>
      <link href="https://realpython.com/python-rock-paper-scissors/"/>
      <updated>2021-01-18T14:00:00+00:00</updated>
      <summary>In this tutorial, you&#x27;ll learn to program rock paper scissors in Python from scratch. You&#x27;ll learn how to take in user input, make the computer choose a random action, determine a winner, and split your code into functions.</summary>
      <content type="html">
        &lt;div&gt;&lt;p&gt;Game programming is a great way to learn how to program. You use many tools that you’ll see in the real world, plus you get to play a game to test your results! An ideal game to start your Python game programming journey is &lt;a href=&quot;https://en.wikipedia.org/wiki/Rock_paper_scissors&quot;&gt;rock paper scissors&lt;/a&gt;. &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;Code your own &lt;strong&gt;rock paper scissors&lt;/strong&gt; game &lt;/li&gt;
&lt;li&gt;Take in user input with &lt;strong&gt;&lt;code&gt;input()&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Play several games in a row using a &lt;strong&gt;&lt;code&gt;while&lt;/code&gt; loop&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Clean up your code with &lt;strong&gt;&lt;code&gt;Enum&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;functions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Define more complex rules with a &lt;strong&gt;dictionary&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;alert alert-warning&quot; role=&quot;alert&quot;&gt;
&lt;p&gt;&lt;strong markdown=&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;what-is-rock-paper-scissors&quot;&gt;What Is Rock Paper Scissors?&lt;a class=&quot;headerlink&quot; href=&quot;#what-is-rock-paper-scissors&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You may have played rock paper scissors before. Maybe you’ve used it to decide who pays for dinner or who gets first choice of players for a team.&lt;/p&gt;
&lt;p&gt;If you’re unfamiliar, rock paper scissors is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hand_game&quot;&gt;hand game&lt;/a&gt; for two or more players. Participants say “rock, paper, scissors” and then simultaneously form their hands into the shape of a rock (a fist), a piece of paper (palm facing downward), or a pair of scissors (two fingers extended). The rules are straightforward: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Rock&lt;/strong&gt; smashes scissors. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Paper&lt;/strong&gt; covers rock.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scissors&lt;/strong&gt; cut paper.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that you have the rules down, you can start thinking about how they might translate to Python code. &lt;/p&gt;
&lt;h2 id=&quot;play-a-single-game-of-rock-paper-scissors-in-python&quot;&gt;Play a Single Game of Rock Paper Scissors in Python&lt;a class=&quot;headerlink&quot; href=&quot;#play-a-single-game-of-rock-paper-scissors-in-python&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Using the description and rules above, you can make a game of rock paper scissors. Before you dive in, you’re going to need to &lt;a href=&quot;https://realpython.com/python-import/&quot;&gt;import&lt;/a&gt; the module you’ll use to simulate the computer’s choices:&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;random&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Awesome! Now you’re able to use the different tools inside &lt;code&gt;random&lt;/code&gt; to randomize the computer’s actions in the game. Now what? Since your users will also need to be able to choose their actions, the first logical thing you need is a way to take in user input.&lt;/p&gt;
&lt;h3 id=&quot;take-user-input&quot;&gt;Take User Input&lt;a class=&quot;headerlink&quot; href=&quot;#take-user-input&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://realpython.com/python-input-output/&quot;&gt;Taking input from a user&lt;/a&gt; is pretty straightforward in Python. The goal here is to ask the user what they would like to choose as an action and then assign that choice to a variable:&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;user_action&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Enter a choice (rock, paper, scissors): &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 will prompt the user to enter a selection and save it to a variable for later use. Now that the user has selected an action, the computer needs to decide what to do.&lt;/p&gt;
&lt;h3 id=&quot;make-the-computer-choose&quot;&gt;Make the Computer Choose&lt;a class=&quot;headerlink&quot; href=&quot;#make-the-computer-choose&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A competitive game of rock paper scissors involves &lt;a href=&quot;https://arstechnica.com/science/2014/05/win-at-rock-paper-scissors-by-knowing-thy-opponent/&quot;&gt;strategy&lt;/a&gt;. Rather than trying to develop a model for that, though, you can save yourself some time by having the computer select a random action. &lt;a href=&quot;https://realpython.com/python-random/&quot;&gt;Random selections&lt;/a&gt; are a great way to have the computer choose a &lt;a href=&quot;https://en.wikipedia.org/wiki/Pseudorandom_number_generator&quot;&gt;pseudorandom&lt;/a&gt; value.&lt;/p&gt;
&lt;p&gt;You can use &lt;strong&gt;&lt;code&gt;random.choice()&lt;/code&gt;&lt;/strong&gt; to have the computer randomly select between the actions:&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;possible_actions&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;rock&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;paper&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;scissors&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;computer_action&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;possible_actions&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 allows a random element to be selected from the list. You can also &lt;a href=&quot;https://realpython.com/python-print/&quot;&gt;print&lt;/a&gt; the choices that the user and the computer made:&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;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;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;You chose &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user_action&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;, computer chose &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;computer_action&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&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;Printing the user and computer actions can be helpful to the user, and it can also help you debug later on in case something isn’t quite right with the outcome.&lt;/p&gt;
&lt;h3 id=&quot;determine-a-winner&quot;&gt;Determine a Winner&lt;a class=&quot;headerlink&quot; href=&quot;#determine-a-winner&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-rock-paper-scissors/?utm_source=realpython&amp;utm_medium=rss&quot;&gt;Read the full article at https://realpython.com/python-rock-paper-scissors/ »&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 #43: Deep Reinforcement Learning in a Notebook With Jupylet + Gaming and Synthesis</title>
      <id>https://realpython.com/podcasts/rpp/43/</id>
      <link href="https://realpython.com/podcasts/rpp/43/"/>
      <updated>2021-01-15T12:00:00+00:00</updated>
      <summary>What is it like to design a Python library for three different audiences?  This week on the show, we have Nir Aides, creator of Jupylet. His new library is designed for deep reinforcement learning researchers, musicians interested in live music coding, and kids interested in learning to program. Everything is designed to run inside of a Jupyter notebook.</summary>
      <content type="html">
        &lt;p&gt;What is it like to design a Python library for three different audiences?  This week on the show, we have Nir Aides, creator of Jupylet. His new library is designed for deep reinforcement learning researchers, musicians interested in live music coding, and kids interested in learning to program. Everything is designed to run inside of a Jupyter notebook.&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>Managing Python Dependencies</title>
      <id>https://realpython.com/courses/managing-python-dependencies/</id>
      <link href="https://realpython.com/courses/managing-python-dependencies/"/>
      <updated>2021-01-12T14:00:00+00:00</updated>
      <summary>Get up to speed with Python dependency management quickly and go from “writing scripts” to “building applications” with this complete course.</summary>
      <content type="html">
        &lt;p&gt;&lt;em&gt;Managing Python Dependencies&lt;/em&gt; is your &amp;ldquo;one-stop shop&amp;rdquo; for picking up modern Python dependency management practices and workflows with minimal time investment.&lt;/p&gt;
&lt;p&gt;The course consists of 32 bite-sized video lessons, each focusing on a single concept. Progressing through the course, you’ll quickly build up a comprehensive knowledge of dependency management best practices in Python at your own, comfortable pace.&lt;/p&gt;
&lt;p&gt;Along the way, you’ll see hands on examples and step-by-step workflows that reinforce the skills you’re learning.&lt;/p&gt;
&lt;p&gt;By the end, you’ll know how to apply Python’s recommended dependency management tools, like pip, virtualenvs, and requirements files effectively in the most common day-to-day development scenarios on Linux, macOS, and Windows.&lt;/p&gt;
&lt;p&gt;With &lt;em&gt;Managing Python Dependencies&lt;/em&gt; you will:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Code at a higher level and become more efficient&lt;/strong&gt;: Leveraging Python&amp;rsquo;s rich third-party library ecosystem let&amp;rsquo;s you write better programs in a shorter amount of time. With a large body of freely available modules you can avoid reinventing the wheel and deliver higher quality Python software, faster. This is a great way for you to demonstrate senior level skills that will benefit your development career.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Get up to speed with Python dependency management quickly&lt;/strong&gt;: Your time is your most important asset. If you can use it efficiently you will save your sanity—and a nice stack of money. This course is concise but thorough and will help you attain solid Python dependency management knowledge fast.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Go from &amp;ldquo;writing scripts&amp;rdquo; to &amp;ldquo;building applications&amp;rdquo; with Python&lt;/strong&gt;: By taking advantage of Python’s rich packaging ecosystem you’ll be able to build substantial and full-featured applications in Python. You’ll know the best practices for finding and documenting application dependencies that put you right on track for deploying and shipping production-grade apps.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Find great libraries for a specific task at hand&lt;/strong&gt;: This course teaches you a unique 7-step workflow for finding and identifying quality Python packages. Find out which libraries and tools are available on PyPI to help you. By quickly and easily identifying the correct libraries you’ll speed up your development efficiency by a large margin. Meet your deadlines and write better code at the same time by not having to &amp;ldquo;reinvent the wheel.&amp;rdquo;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Master &amp;ldquo;the tools of the trade&amp;rdquo; for dependency management&lt;/strong&gt;: With this course you’ll master the tools and workflows recommended by the official Python Packaging Authority. By getting those skills under your belt you’ll be ready to work with the Python development and production environments used by professional development teams across the world. Knowing these &amp;ldquo;tools of the trade&amp;rdquo; by heart puts you at an advantage in any job interview situation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;Productionize&amp;rdquo; your projects and share them with the world&lt;/strong&gt;: You’ll see how to apply the best practices for defining and installing package dependencies in Python. You&amp;rsquo;ll know how to get your programs ready to be deployed on production and automated testing environments and how to make it easy for other developers to contribute code with minimal setup effort.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Become more valuable as an employee and team member&lt;/strong&gt;: With my detailed 7-step workflow for researching quality Python packages you’ll know how to document and justify added program dependencies to your team and your manager. By taking on more responsibilities and picking up these senior-level &amp;ldquo;architectural&amp;rdquo; skills you’ll rise head and shoulders above other devs stuck at the &amp;ldquo;code monkey&amp;rdquo; level.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;who-is-this-course-for&quot;&gt;Who Is This Course For?&lt;a class=&quot;headerlink&quot; href=&quot;#who-is-this-course-for&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;This course is for Python developers&lt;/strong&gt; wanting to break through to the next phase of developing code by becoming more efficient, productive, and skilled using Python&amp;rsquo;s rich library ecosystem.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;ve ever caught yourself thinking &lt;em&gt;&amp;ldquo;There&amp;rsquo;s got to be a Python package out there that does exactly what I want&amp;hellip;But how do I find it?&amp;rdquo;&lt;/em&gt; this course will fill in the missing pieces for you.&lt;/p&gt;
&lt;p&gt;Discover the industry best practices around choosing and managing third-party dependencies for your Python 2 or Python 3 projects on Windows, macOS, and Linux.&lt;/p&gt;
&lt;p&gt;If you already know how to use alternative package managers like &lt;em&gt;Conda&lt;/em&gt; you&amp;rsquo;ll discover how to use the standards-compliant tools and workflows supported by any Python distribution and used in most production application deployments.&lt;/p&gt;
&lt;h2 id=&quot;course-goals&quot;&gt;Course Goals&lt;a class=&quot;headerlink&quot; href=&quot;#course-goals&quot; title=&quot;Permanent link&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;By the end of the course you’ll know how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Install, use, and manage third-party Python packages with the &amp;ldquo;pip&amp;rdquo; package manager on Windows, macOS, and Linux.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Isolate project dependencies with so-called virtual environments to avoid version conflicts in your Python projects.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Apply a complete 7-step workflow for finding and identifying quality third-party packages to use in your own Python projects (and justifying your decisions to your team or manager.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up repeatable development environments and application deployments using the &amp;ldquo;pip&amp;rdquo; package manager and requirements files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #42: What Is Data Engineering and Researching 10 Million Jupyter Notebooks</title>
      <id>https://realpython.com/podcasts/rpp/42/</id>
      <link href="https://realpython.com/podcasts/rpp/42/"/>
      <updated>2021-01-08T12:00:00+00:00</updated>
      <summary>Are you familiar with the role data engineers play in the modern landscape of data science and Python? Data engineering is a sub-discipline that focuses on the transportation, transformation, and storage of data.  This week on the show, David Amos is back, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.</summary>
      <content type="html">
        &lt;p&gt;Are you familiar with the role data engineers play in the modern landscape of data science and Python? Data engineering is a sub-discipline that focuses on the transportation, transformation, and storage of data.  This week on the show, David Amos is back, and he&#x27;s brought another batch of PyCoder&#x27;s Weekly articles and projects.&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>Building HTTP APIs With Django REST Framework</title>
      <id>https://realpython.com/courses/django-rest-framework/</id>
      <link href="https://realpython.com/courses/django-rest-framework/"/>
      <updated>2021-01-05T14:00:00+00:00</updated>
      <summary>This course will get you ready to build HTTP APIs with Django REST Framework. The Django REST framework (DRF) is a toolkit built on top of the Django web framework that reduces the amount of code you need to write to create REST interfaces.</summary>
      <content type="html">
        &lt;p&gt;REST is a loosely defined protocol for listing, creating, changing, and deleting data on your server over HTTP. The Django REST framework (DRF) is a toolkit built on top of the Django web framework that reduces the amount of code you need to write to create REST HTTP API interfaces.&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;REST protocol&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;DRF &lt;strong&gt;&lt;code&gt;Serializers&lt;/code&gt;&lt;/strong&gt; and how to use them with Django objects&lt;/li&gt;
&lt;li&gt;Using Django &lt;code&gt;views&lt;/code&gt; and DRF &lt;code&gt;ViewSet&lt;/code&gt; classes to create REST &lt;strong&gt;end-points&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Multiple flavors of &lt;strong&gt;renderers&lt;/strong&gt; and how to control their output&lt;/li&gt;
&lt;li&gt;Specifying &lt;strong&gt;permissions&lt;/strong&gt; and limiting who can see what data in your REST API&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>Django Admin Customization</title>
      <id>https://realpython.com/courses/django-admin-customization/</id>
      <link href="https://realpython.com/courses/django-admin-customization/"/>
      <updated>2020-12-29T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn how to customize Django&#x27;s admin with Python. You&#x27;ll use AdminModel objects to add display columns, calculate values, link to referring objects, and search and filter results. You&#x27;ll also use template overriding to gain full control over the admin&#x27;s HTML.</summary>
      <content type="html">
        &lt;p&gt;The &lt;a href=&quot;https://www.djangoproject.com/&quot;&gt;&lt;strong&gt;Django&lt;/strong&gt;&lt;/a&gt; framework comes with a powerful &lt;a href=&quot;https://docs.djangoproject.com/en/3.0/ref/contrib/admin/&quot;&gt;administrative tool&lt;/a&gt; called &lt;strong&gt;admin&lt;/strong&gt;. You can use it out of the box to quickly add, delete, or edit any database model from a web interface. But with a little extra code, you can customize the Django admin to take your admin capabilities to the next level.&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;Add &lt;strong&gt;attribute columns&lt;/strong&gt; in the model object list &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Link&lt;/strong&gt; between model objects&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;filters&lt;/strong&gt; to the model object list&lt;/li&gt;
&lt;li&gt;Make model object lists &lt;strong&gt;searchable&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Modify the object &lt;strong&gt;edit forms&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Override Django &lt;strong&gt;admin templates&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #41: 2020 Real Python Articles in Review</title>
      <id>https://realpython.com/podcasts/rpp/41/</id>
      <link href="https://realpython.com/podcasts/rpp/41/"/>
      <updated>2020-12-25T12:00:00+00:00</updated>
      <summary>It&#x27;s been quite the year! The Real Python team has written, edited, curated, illustrated, and produced a mountain of Python articles this year. We also upgraded the site and membership with office hours, transcripts, this podcast, and much more. 

We are joined by two members of the Real Python team, David Amos and Joanna Jablonski. We wanted to share a year-end wrap-up with a collection of articles that showcase a diversity of Python topics and the quality of what our team created this year.</summary>
      <content type="html">
        &lt;p&gt;It&#x27;s been quite the year! The Real Python team has written, edited, curated, illustrated, and produced a mountain of Python articles this year. We also upgraded the site and membership with office hours, transcripts, this podcast, and much more. 

We are joined by two members of the Real Python team, David Amos and Joanna Jablonski. We wanted to share a year-end wrap-up with a collection of articles that showcase a diversity of Python topics and the quality of what our team created this year.&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>Serializing Objects With the Python pickle Module</title>
      <id>https://realpython.com/courses/pickle-serializing-objects/</id>
      <link href="https://realpython.com/courses/pickle-serializing-objects/"/>
      <updated>2020-12-22T14:00:00+00:00</updated>
      <summary>In this course, you&#x27;ll learn how you can use the Python pickle module to convert your objects into a stream of bytes that can be saved to a disk or sent over a network. You&#x27;ll also learn the security implications of using this process on objects from an untrusted source.</summary>
      <content type="html">
        &lt;p&gt;As a developer, you may sometimes need to send complex object hierarchies over a network or save the internal state of your objects to a disk or database for later use. To accomplish this, you can use a process called &lt;strong&gt;serialization&lt;/strong&gt;, which is fully supported by the standard library thanks to the Python &lt;strong&gt;&lt;code&gt;pickle&lt;/code&gt;&lt;/strong&gt; module.&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;What it means to &lt;strong&gt;serialize&lt;/strong&gt; and &lt;strong&gt;deserialize&lt;/strong&gt; an object&lt;/li&gt;
&lt;li&gt;Which &lt;strong&gt;modules&lt;/strong&gt; you can use to serialize objects in Python&lt;/li&gt;
&lt;li&gt;Which kinds of objects can be serialized with the Python &lt;strong&gt;&lt;code&gt;pickle&lt;/code&gt;&lt;/strong&gt; module&lt;/li&gt;
&lt;li&gt;How to use the Python &lt;code&gt;pickle&lt;/code&gt; module to serialize &lt;strong&gt;object hierarchies&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;What the &lt;strong&gt;risks&lt;/strong&gt; are when deserializing an object from an untrusted source&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 #40: How Python Manages Memory and Creating Arrays With np.linspace</title>
      <id>https://realpython.com/podcasts/rpp/40/</id>
      <link href="https://realpython.com/podcasts/rpp/40/"/>
      <updated>2020-12-18T12:00:00+00:00</updated>
      <summary>Have you wondered how Python manages memory? How are your variables stored in memory, and when do they get deleted? This week on the show, David Amos is here, and he has brought another batch of PyCoder&#x27;s Weekly articles and projects.

Along with the Real Python article on Python memory management, we also talk about another article about creating even and non-even spaced arrays in Python with np.linspace.</summary>
      <content type="html">
        &lt;p&gt;Have you wondered how Python manages memory? How are your variables stored in memory, and when do they get deleted? This week on the show, David Amos is here, and he has brought another batch of PyCoder&#x27;s Weekly articles and projects.

Along with the Real Python article on Python memory management, we also talk about another article about creating even and non-even spaced arrays in Python with np.linspace.&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 Turtle for Beginners</title>
      <id>https://realpython.com/courses/python-turtle-beginners/</id>
      <link href="https://realpython.com/courses/python-turtle-beginners/"/>
      <updated>2020-12-15T14:00:00+00:00</updated>
      <summary>In this step-by-step course, you&#x27;ll learn the basics of Python programming with the help of a simple and interactive Python library called turtle. If you&#x27;re a beginner to Python, then this course will definitely help you on your journey as you take your first steps into the world of programming.</summary>
      <content type="html">
        &lt;p&gt;In this step-by-step course, you&amp;rsquo;ll learn the basics of Python programming with the help of a simple and interactive Python library called turtle. If you&amp;rsquo;re a beginner to Python, then this course will definitely help you on your journey as you take your first steps into the world of programming. The Python &lt;code&gt;turtle&lt;/code&gt; library comes with a similar interactive feature that gives new programmers a taste of what it&amp;rsquo;s like to work with Python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In this course, you will:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Understand&lt;/strong&gt; what the Python &lt;code&gt;turtle&lt;/code&gt; library is&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Learn&lt;/strong&gt; how to set &lt;code&gt;turtle&lt;/code&gt; up on your computer&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Program&lt;/strong&gt; with the Python &lt;code&gt;turtle&lt;/code&gt; library&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Grasp&lt;/strong&gt; some important Python concepts and &lt;code&gt;turtle&lt;/code&gt; commands&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Develop&lt;/strong&gt; a short but entertaining game using what you&amp;rsquo;ve learned&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 #39: Generators, Coroutines, and Learning Python Through Exercises</title>
      <id>https://realpython.com/podcasts/rpp/39/</id>
      <link href="https://realpython.com/podcasts/rpp/39/"/>
      <updated>2020-12-11T12:00:00+00:00</updated>
      <summary>Have you started to use generators in Python? Are you unsure why you would even use one over a regular function? How do you use the special &quot;send&quot; method and the &quot;yield from&quot; syntax? This week on the show, we have Reuven Lerner to talk about his PyCon Africa 2020 talk titled &quot;Generators, coroutines, and nanoservices.&quot;</summary>
      <content type="html">
        &lt;p&gt;Have you started to use generators in Python? Are you unsure why you would even use one over a regular function? How do you use the special &quot;send&quot; method and the &quot;yield from&quot; syntax? This week on the show, we have Reuven Lerner to talk about his PyCon Africa 2020 talk titled &quot;Generators, coroutines, and nanoservices.&quot;&lt;/p&gt;
        &lt;hr /&gt;
        &lt;p&gt;&lt;em&gt;[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short &amp;amp; sweet Python Trick delivered to your inbox every couple of days. &lt;a href=&quot;https://realpython.com/python-tricks/?utm_source=realpython&amp;amp;utm_medium=rss&amp;amp;utm_campaign=footer&quot;&gt;&amp;gt;&amp;gt; Click here to learn more and see examples&lt;/a&gt; ]&lt;/em&gt;&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <title>The Real Python Podcast – Episode #38: Looping With enumerate() and Python GUIs With PyQt</title>
      <id>https://realpython.com/podcasts/rpp/38/</id>
      <link href="https://realpython.com/podcasts/rpp/38/"/>
      <updated>2020-12-04T12:00:00+00:00</updated>
      <summary>If you&#x27;re coming to Python from a different language, you may not know about a useful tool for working with loops, Python&#x27;s built-in enumerate function. This week on the show, David Amos is here, and he has brought another batch of PyCoder&#x27;s Weekly articles and projects.

Along with the Real Python article covering the details of the enumerate function, we also talk about another article about constructing Python graphical user interface elements in PyQt.</summary>
      <content type="html">
        &lt;p&gt;If you&#x27;re coming to Python from a different language, you may not know about a useful tool for working with loops, Python&#x27;s built-in enumerate function. This week on the show, David Amos is here, and he has brought another batch of PyCoder&#x27;s Weekly articles and projects.

Along with the Real Python article covering the details of the enumerate function, we also talk about another article about constructing Python graphical user interface elements in PyQt.&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>
