Real Python2026-02-13T12:00:00+00:00https://realpython.com/Real PythonThe Real Python Podcast – Episode #284: Running Local LLMs With Ollama and Connecting With Pythonhttps://realpython.com/podcasts/rpp/284/2026-02-13T12:00:00+00:00Would you like to learn how to work with LLMs locally on your own computer? How do you integrate your Python projects with a local model? Christopher Trudeau is back on the show this week with another batch of PyCoder's Weekly articles and projects.
<p>Would you like to learn how to work with LLMs locally on your own computer? How do you integrate your Python projects with a local model? Christopher Trudeau is back on the show this week with another batch of PyCoder's Weekly articles and projects.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: Python's list Data Type: A Deep Dive With Exampleshttps://realpython.com/quizzes/python-list/2026-02-12T12:00:00+00:00Check your Python list skills with quick tasks on indexing, slicing, methods, copies, comprehensions, and pitfalls.
<p>Get hands-on with Python lists in this quick quiz. You’ll revisit indexing and slicing, update items in place, and compare list methods.</p>
<p>Along the way, you’ll look at reversing elements, using the <code>list()</code> constructor and the <code>len()</code> function, and distinguishing between shallow and deep copies. For a refresher, see the Real Python guide to <a href="https://realpython.com/python-list/">Python lists</a>.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
What Exactly Is the Zen of Python?https://realpython.com/zen-of-python/2026-02-11T14:00:00+00:00The Zen of Python is a collection of 19 guiding principles for writing good Python code. Learn its history, meaning, and hidden jokes.
<div><p>The <strong>Zen of Python</strong> is a collection of 19 aphorisms that capture the guiding principles behind Python’s design. You can display them anytime by running <code>import this</code> in a Python REPL. Tim Peters wrote them in 1999 as a joke, but they became an iconic part of Python culture that was even formalized as <a href="/ref/glossary/pep/" class="ref-link">PEP</a> 20.</p>
<p><strong>By the end of this tutorial, you’ll understand:</strong></p>
<ul>
<li>The Zen of Python is a <strong>humorous poem</strong> of 19 aphorisms describing Python’s design philosophy</li>
<li>Running <code>import this</code> in a Python <a href="/ref/glossary/interpreter/" class="ref-link">interpreter</a> displays the <strong>complete text</strong> of the Zen of Python</li>
<li><strong>Tim Peters</strong> wrote the Zen of Python in 1999 as a tongue-in-cheek comment on a mailing list</li>
<li>The aphorisms are <strong>guidelines, not strict rules</strong>, and some intentionally contradict each other</li>
<li>The principles promote <strong>readability, simplicity, and explicitness</strong> while acknowledging that practicality matters</li>
</ul>
<p>Experienced Pythonistas often refer to the Zen of Python as a source of wisdom and guidance, especially when they want to settle an argument about certain design decisions in a piece of code.
In this tutorial, you’ll explore the origins of the Zen of Python, learn how to interpret its mysterious aphorisms, and discover the Easter eggs hidden within it.</p>
<p>You don’t need to be a Python master to understand the Zen of Python! But you do need to answer an important question: <strong>What exactly is the Zen of Python?</strong></p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Free Bonus:</strong> <a href="https://realpython.com/bonus/python-easter-eggs/" class="alert-link" data-toggle="modal" data-target="#modal-python-easter-eggs" markdown>Click here to download your Easter egg hunt</a> to discover what’s hidden inside Python!</p>
</div>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “What Exactly Is the Zen of Python?” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/zen-of-python/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #b9abe6;" alt="What's the Zen of Python?" src="https://files.realpython.com/media/Whats-the-Zen-of-Python_Watermarked.3ec4785e1bb9.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Whats-the-Zen-of-Python_Watermarked.3ec4785e1bb9.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Whats-the-Zen-of-Python_Watermarked.3ec4785e1bb9.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Whats-the-Zen-of-Python_Watermarked.3ec4785e1bb9.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Whats-the-Zen-of-Python_Watermarked.3ec4785e1bb9.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/zen-of-python/" class="stretched-link"><span class="my-0 h4">What Exactly Is the Zen of Python?</span></a>
<p class="text-muted mb-0 small">Learn and test the Zen of Python, its guiding aphorisms, and tips for writing clearer, more readable, and maintainable code.</p>
</div>
</div>
</div>
<h2 id="in-short-its-a-humorous-poem-listing-python-philosophies">In Short: It’s a Humorous Poem Listing Python Philosophies<a class="headerlink" href="#in-short-its-a-humorous-poem-listing-python-philosophies" title="Permanent link"></a></h2>
<p>According to the <a href="https://docs.python.org/3/glossary.html">Python glossary</a>, which contains definitions of popular terms related to this programming language, the <strong>Zen of Python</strong> is a:</p>
<blockquote>
<p>Listing of Python design principles and philosophies that are helpful in understanding and using the language. The listing can be found by typing “<code>import this</code>” at the interactive prompt. (<a href="https://docs.python.org/3/glossary.html#term-Zen-of-Python">Source</a>)</p>
</blockquote>
<p>Indeed, when you type the indicated <a href="https://realpython.com/python-import/"><code>import</code> statement</a> into an interactive <a href="https://realpython.com/python-repl/">Python REPL</a>, then you’ll be presented with the nineteen aphorisms that make up the Zen of Python:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="pycon" data-is-repl="true">
<div class="codeblock__header codeblock--blue">
<span class="mr-2 noselect" aria-label="Language">Python</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">this</span>
<span class="go">The Zen of Python, by Tim Peters</span>
<span class="go">Beautiful is better than ugly.</span>
<span class="go">Explicit is better than implicit.</span>
<span class="go">Simple is better than complex.</span>
<span class="go">Complex is better than complicated.</span>
<span class="go">Flat is better than nested.</span>
<span class="go">Sparse is better than dense.</span>
<span class="go">Readability counts.</span>
<span class="go">Special cases aren't special enough to break the rules.</span>
<span class="go">Although practicality beats purity.</span>
<span class="go">Errors should never pass silently.</span>
<span class="go">Unless explicitly silenced.</span>
<span class="go">In the face of ambiguity, refuse the temptation to guess.</span>
<span class="go">There should be one-- and preferably only one --obvious way to do it.</span>
<span class="go">Although that way may not be obvious at first unless you're Dutch.</span>
<span class="go">Now is better than never.</span>
<span class="go">Although never is often better than *right* now.</span>
<span class="go">If the implementation is hard to explain, it's a bad idea.</span>
<span class="go">If the implementation is easy to explain, it may be a good idea.</span>
<span class="go">Namespaces are one honking great idea -- let's do more of those!</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>The byline reveals the poem’s author, <a href="https://en.wikipedia.org/wiki/Tim_Peters_(software_engineer)">Tim Peters</a>, who’s a renowned software engineer and a long-standing <a href="https://realpython.com/cpython-source-code-guide/">CPython</a> core developer best known for inventing the <a href="https://realpython.com/sorting-algorithms-python/#the-timsort-algorithm-in-python">Timsort</a> sorting algorithm. He also authored the <a href="https://realpython.com/python-doctest/"><code>doctest</code></a> and <a href="https://realpython.com/python-timer/#estimating-running-time-with-timeit"><code>timeit</code></a> modules in the Python <a href="/ref/glossary/standard-library/" class="ref-link">standard library</a>, along with making many other contributions.</p>
<p>Take your time to read through the Zen of Python and contemplate its wisdom. But don’t take the aphorisms literally, as they’re more of a guiding set of principles rather than strict instructions. You’ll learn about their humorous origins in the next section.</p>
<h2 id="how-did-the-zen-of-python-originate">How Did the Zen of Python Originate?<a class="headerlink" href="#how-did-the-zen-of-python-originate" title="Permanent link"></a></h2>
<p>The idea of formulating a single document that would encapsulate Python’s fundamental philosophies emerged among the core developers in June 1999. As more and more people began coming to Python from other programming languages, they’d often bring their preconceived notions of software design that weren’t necessarily <a href="https://realpython.com/learning-paths/writing-pythonic-code/">Pythonic</a>. To help them follow the spirit of the language, a set of recommendations for writing idiomatic Python was needed.</p>
<p>The initial discussion about creating such a document took place on the Python mailing list under the subject <em>The Python Way</em>. Today, you can find this conversation in the official <a href="https://mail.python.org/pipermail/python-list/1999-June/subject.html">Python-list archive</a>. If you look closely at the <a href="https://mail.python.org/pipermail/python-list/1999-June/001951.html">first message from Tim Peters</a> in that thread, then you’ll notice that he clearly outlined the Zen of Python as a joke. That original form has stuck around until this day:</p>
<blockquote>
<p>Clearly a job for Guido alone – although I doubt it’s one he’ll take on
(fwiw, I wish he would too!). Here’s the outline he would start from,
though <wink>:</p>
<p>Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than <em>right</em> now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea – let’s do more of those!</p>
<p>There you go: 20 Pythonic Fec^H^H^HTheses on the nose, counting the one I’m
leaving for Guido to fill in. If the answer to <em>any</em> Python design issue
isn’t obvious after reading those – well, I just give up <wink>. (<a href="https://mail.python.org/pipermail/python-list/1999-June/001951.html">Source</a>)</p>
</blockquote>
<p>The wink and the playful way of self-censoring some <a href="https://en.wikipedia.org/wiki/Toilet_humour">toilet humor</a> are clear giveaways that Tim Peters didn’t want anyone to take his comment too seriously.</p>
<div class="alert alert-primary" role="alert">
<p><strong>Note:</strong> In case you didn’t get the joke, he started to write something like <em>Feces</em> but then used <code>^H</code>—which represents a <span class="keys"><kbd class="key-backspace">Backspace</kbd></span> in older text editors like <a href="https://realpython.com/vim-and-python-a-match-made-in-heaven/">Vim</a>—to delete the last three letters and make the word <em>Theses</em>. Therefore, the intended phrase is <em>20 Pythonic Theses</em>.</p>
</div>
<p>Eventually, these nearly twenty theses got a proper name and were formally codified in a <a href="https://peps.python.org/pep-0001/">Python Enhancement Proposal</a> document. Each PEP document receives a number. For example, you might have stumbled on <a href="https://realpython.com/python-pep8/">PEP 8</a>, which is the style guide for writing readable Python code. Perhaps as an inside joke, the Zen of Python received the number <a href="https://peps.python.org/pep-0020/">PEP 20</a> to signify the incomplete number of aphorisms in it.</p>
<p>To win your next argument about what makes good Python code, you can back up your claims with the Zen of Python. If you’d like to refer to a specific aphorism instead of the entire poem, then consider visiting <a href="https://pep20.org/">pep20.org</a>, which provides convenient clickable links to each principle.</p>
<p>And, in case you want to learn the poem by heart while having some fun, you can now listen to a <a href="https://www.youtube.com/watch?v=i6G6dmVJy74">song</a> with the Zen of Python as its lyrics. <a href="https://barry.warsaw.us/">Barry Warsaw</a>, another core developer involved with Python since its early days, composed and performed this musical rendition. The song became the closing track on a special vinyl record entitled <a href="https://www.edgedb.com/blog/the-zen-side-of-the-moon"><em>The Zen Side of the Moon</em></a>, which was <a href="https://x.com/pyladies/status/1649988104433061888">auctioned</a> at <a href="https://realpython.com/python-news-april-2023/#pycon-us-2023-celebrates-its-twentieth-anniversary">PyCon US 2023</a>.</p>
<p>Okay. Now that you have a rough idea of what the Zen of Python is and how it came about, you might be asking yourself whether you should really follow it.</p>
<h2 id="should-you-obey-the-zen-of-python">Should You Obey the Zen of Python?<a class="headerlink" href="#should-you-obey-the-zen-of-python" title="Permanent link"></a></h2>
</div><h2><a href="https://realpython.com/zen-of-python/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/zen-of-python/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: What Exactly Is the Zen of Python?https://realpython.com/quizzes/zen-of-python/2026-02-11T12:00:00+00:00Learn and test the Zen of Python, its guiding aphorisms, and tips for writing clearer, more readable, and maintainable code.
<p>In this quiz, you’ll test your understanding of <a href="https://realpython.com/zen-of-python/">The Zen of Python</a>.</p>
<p>By working through this quiz, you’ll revisit core aphorisms and learn how they guide readable, maintainable, and Pythonic code.</p>
<p>The questions explore practical tradeoffs like breaking dense expressions into smaller parts, favoring clarity over cleverness, and making code behavior explicit.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Improving Your Tests With the Python Mock Object Libraryhttps://realpython.com/courses/improve-tests-mock-object-library/2026-02-10T14:00:00+00:00Master Python testing with unittest.mock. Create mock objects to tame complex logic and unpredictable dependencies.
<p>When you’re writing robust code, <strong>tests</strong> are essential for verifying that your application logic is correct, reliable, and efficient. However, the value of your tests depends on how well they demonstrate these qualities. Obstacles such as <strong>complex logic</strong> and unpredictable <strong>dependencies</strong> can make writing valuable tests challenging. The Python mock object library, <strong><code>unittest.mock</code></strong>, can help you overcome these obstacles.</p>
<p><strong>By the end of this course, you’ll be able to:</strong></p>
<ul>
<li>Create Python mock objects using <code>Mock</code></li>
<li>Assert that you’re using objects as you intended</li>
<li>Inspect usage data stored on your Python mocks</li>
<li>Configure certain aspects of your Python mock objects</li>
<li>Substitute your mocks for real objects using <code>patch()</code></li>
<li>Avoid common problems inherent in Python mocking</li>
</ul>
<p>You’ll begin by learning what mocking is and how it will improve your tests!</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: Python's pathlib Module: Taming the File Systemhttps://realpython.com/quizzes/python-pathlib/2026-02-10T12:00:00+00:00Revisit Python's pathlib module for handling file and folder paths consistently across operating systems. Write modern, object-oriented code.
<p>In this quiz, you’ll revisit how to <a href="https://realpython.com/python-pathlib/">tame the file system with Python’s <code>pathlib</code> module</a>.</p>
<p>You’ll reinforce core <code>pathlib</code> concepts, including checking whether a path points to a file and instantiating <code>Path</code> objects. You’ll revisit joining paths with the <code>/</code> operator and <code>.joinpath()</code>, iterating over directory contents with <code>.iterdir()</code>, and renaming files on disk with <code>.replace()</code>.</p>
<p>You’ll also check your knowledge of common file operations such as creating empty files with <code>.touch()</code>, writing text with <code>.write_text()</code>, and extracting filename components using <code>.stem</code> and <code>.suffix</code>.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
pandas 3.0 Lands Breaking Changes and Other Python News for February 2026https://realpython.com/python-news-february-2026/2026-02-09T14:00:00+00:00Catch up on the latest Python news: pandas 3.0 breaking changes, Python 3.15 alpha JIT gains, PyTorch 2.10 deprecations, and PSF updates.
<div><p>Last month brought exciting performance news for Python! The <strong>Python 3.15 alphas</strong> showed JIT compiler speed gains of up to 7–8% on some platforms, while <strong>pandas released version 3.0</strong>, delivering the most significant performance improvements in years. The Python Software Foundation also received considerable investments in Python security and launched the 2026 Python Developers Survey, and PyTorch 2.10 deprecated TorchScript.</p>
<p>Time to dive into the biggest Python news from the past month!</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Join Now:</strong> <a href="https://realpython.com/bonus/newsletter/" class="alert-link" data-toggle="modal" data-target="#modal-newsletter" markdown>Click here to join the Real Python Newsletter</a> and you’ll never miss another Python tutorial, course, or news update.</p>
</div>
<h2 id="python-releases-and-pep-highlights">Python Releases and PEP Highlights<a class="headerlink" href="#python-releases-and-pep-highlights" title="Permanent link"></a></h2>
<p>Last month brought two Python 3.15 alpha releases in quick succession, with notable <a href="https://realpython.com/python313-free-threading-jit/">JIT compiler</a> improvements showing promising performance gains. Several <a href="/ref/glossary/pep/" class="ref-link">PEPs</a> also emerged, including one proposing a cleaner way to write multiline strings.</p>
<h3 id="python-3150-alpha-4-and-5-two-releases-in-two-days">Python 3.15.0 Alpha 4 and 5: Two Releases in Two Days<a class="headerlink" href="#python-3150-alpha-4-and-5-two-releases-in-two-days" title="Permanent link"></a></h3>
<p>January saw an unusual situation in Python’s release history: <a href="https://pythoninsider.blogspot.com/2026/01/python-3150-alpha-4.html">Python 3.15.0a4</a> arrived on January 13, but it was accidentally compiled against outdated source code from December 2025. The release team quickly followed up with <a href="https://www.python.org/downloads/release/python-3150a5/">3.15.0a5</a> on January 14 to correct the issue.</p>
<p>Both releases continue the work on Python 3.15’s headline features:</p>
<ul>
<li><strong>UTF-8 as the default <a href="https://realpython.com/python-encodings-guide/">text encoding</a></strong> for files that don’t specify an encoding, via <a href="https://peps.python.org/pep-0686/">PEP 686</a></li>
<li>A <strong>new statistical sampling profiler</strong> that’s high-frequency and low-overhead, via <a href="https://peps.python.org/pep-0799/">PEP 799</a></li>
<li>The <strong><code>PyBytesWriter</code> C API</strong> for creating <a href="https://realpython.com/python-bytes/"><code>bytes</code> objects</a> more efficiently, via <a href="https://peps.python.org/pep-0782/">PEP 782</a></li>
<li><strong>Enhanced error messages</strong> with improved clarity and usefulness</li>
</ul>
<p>The most exciting news for performance enthusiasts is the continued progress on Python’s experimental JIT compiler. Alpha 5 reports a <strong>4–5% performance improvement on x86-64 Linux</strong> and a <strong>7–8% speedup on AArch64 macOS</strong> compared to the standard <a href="/ref/glossary/interpreter/" class="ref-link">interpreter</a>.</p>
<div class="alert alert-primary" role="alert">
<p><strong>Note:</strong> These are preview releases and are not recommended for production. The beta phase begins May 5, 2026, with the next alpha, 3.15.0a6, scheduled for February 10, 2026.</p>
</div>
<p>If you maintain packages, now is a good time to <a href="https://realpython.com/python-pre-release/">start running tests against the alphas</a> in a separate environment so you can catch regressions early.</p>
<h3 id="pep-822-drafted-dedented-multiline-strings-d-strings">PEP 822 Drafted: Dedented Multiline Strings (d-strings)<a class="headerlink" href="#pep-822-drafted-dedented-multiline-strings-d-strings" title="Permanent link"></a></h3>
<p>A new <a href="/ref/glossary/pep/" class="ref-link">PEP</a> emerged in January that could make writing multiline strings clearer. <a href="https://peps.python.org/pep-0822/">PEP 822</a>, authored by Inada Naoki, proposes adding <strong>dedented multiline strings</strong> (d-strings) to Python.</p>
<p>If you’ve ever written a <a href="https://realpython.com/python-strings/">multiline string</a> inside an indented function or class, you’ve likely run into the awkward choice between breaking your code’s visual structure or using <a href="https://docs.python.org/3/library/textwrap.html#textwrap.dedent"><code>textwrap.dedent()</code></a> to clean up the extra whitespace. PEP 822 offers a cleaner solution with a new <code>d</code> prefix:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="python">
<div class="codeblock__header codeblock--blue">
<span class="mr-2 noselect" aria-label="Language">Python</span>
<div class="noselect">
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="k">def</span><span class="w"> </span><span class="nf">get_help_message</span><span class="p">():</span>
<span class="c1"># Current approach</span>
<span class="k">return</span> <span class="n">textwrap</span><span class="o">.</span><span class="n">dedent</span><span class="p">(</span><span class="s2">"""</span><span class="se">\</span>
<span class="s2"> Usage: app [options]</span>
<span class="s2"> Options:</span>
<span class="s2"> -h Show this help message</span>
<span class="s2"> -v Enable verbose mode</span>
<span class="s2"> """</span><span class="p">)</span>
<span class="c1"># Proposed d-string approach</span>
<span class="k">return</span> <span class="n">d</span><span class="s2">"""</span>
<span class="s2"> Usage: app [options]</span>
<span class="s2"> Options:</span>
<span class="s2"> -h Show this help message</span>
<span class="s2"> -v Enable verbose mode</span>
<span class="s2"> """</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>The <code>d</code> prefix tells Python to automatically strip the common leading whitespace from each line, using the indentation of the closing quotes as a reference. This differs slightly from <code>textwrap.dedent()</code>, which uses the least-indented line to determine how much to strip.</p>
<p>The proposal targets <strong>Python 3.15</strong> and is currently in draft status. If you work with templates, <a href="https://realpython.com/python-sql-libraries/">SQL</a> queries, or any code that embeds multiline text, this feature could simplify your workflow. You can follow the discussion on the <a href="https://discuss.python.org/t/pep-822-dedented-multiline-string-d-string/105519">Python Discourse</a> and provide feedback while the PEP is still being refined.</p>
<h2 id="psf-news-investments-fellows-and-survey">PSF News: Investments, Fellows, and Survey<a class="headerlink" href="#psf-news-investments-fellows-and-survey" title="Permanent link"></a></h2>
<p>The <a href="/ref/glossary/psf/" class="ref-link">Python Software Foundation (PSF)</a> had a busy month with a major security investment announcement, new Fellows recognition, and the launch of the annual developers survey.</p>
<h3 id="anthropic-invests-in-python-security">Anthropic Invests in Python Security<a class="headerlink" href="#anthropic-invests-in-python-security" title="Permanent link"></a></h3>
</div><h2><a href="https://realpython.com/python-news-february-2026/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/python-news-february-2026/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #283: Improving Your GitHub Developer Experiencehttps://realpython.com/podcasts/rpp/283/2026-02-06T12:00:00+00:00What are ways to improve how you're using GitHub? How can you collaborate more effectively and improve your technical writing? This week on the show, Adam Johnson is back to talk about his new book, "Boost Your GitHub DX: Tame the Octocat and Elevate Your Productivity".
<p>What are ways to improve how you're using GitHub? How can you collaborate more effectively and improve your technical writing? This week on the show, Adam Johnson is back to talk about his new book, "Boost Your GitHub DX: Tame the Octocat and Elevate Your Productivity".</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Why You Should Attend a Python Conferencehttps://realpython.com/python-conference-guide/2026-02-04T14:00:00+00:00Attending a Python conference can grow your network, skills, and confidence. Follow this guide to take your first steps toward joining a Python event.
<div><p>The idea of attending a Python conference can feel intimidating. You might wonder if you know enough, if you’ll fit in, or if it’s worth your time and money. In this guide, you’ll learn about the different types of Python conferences, what they actually offer, who they’re for, and how attending one can support your learning, confidence, and connection to the wider Python community.</p>
<h2 id="prerequisites">Prerequisites<a class="headerlink" href="#prerequisites" title="Permanent link"></a></h2>
<p>This guide is for all Python users who want to grow their Python knowledge, get involved with the Python community, or explore new professional opportunities. Your level of experience with Python doesn’t matter, and neither does whether you use Python professionally or as a hobbyist—regularly or only from time to time.
If you use Python, you’re a Python developer, and Python conferences are <em>for</em> Python developers!</p>
<p><a href="https://realpython.com/podcasts/rpp/249/">Brett Cannon</a>, a <a href="/ref/glossary/cpython/" class="ref-link">CPython</a> core developer, once said:</p>
<blockquote>
<p>I came for the language, but I stayed for the community. (<a href="https://youtu.be/L_LLYTm-QnM?si=p-KBFHKgxqgdg357&t=1006">Source</a>)</p>
</blockquote>
<p>If you want to experience this feeling firsthand, then this guide is for you.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your PDF:</strong> <a href="https://realpython.com/bonus/python-conference-guide-cheatsheet/" class="alert-link" data-toggle="modal" data-target="#modal-python-conference-guide-cheatsheet" markdown>Click here to download a PDF</a> with practical tips to help you feel prepared for your first Python conference.</p>
</div>
<h2 id="understand-what-python-conferences-actually-offer">Understand What Python Conferences Actually Offer<a class="headerlink" href="#understand-what-python-conferences-actually-offer" title="Permanent link"></a></h2>
<p>Attending a Python conference offers several distinct benefits that generally fall into three categories:</p>
<ul>
<li>
<p><strong>Personal growth</strong>: Learn new concepts, tools, and best practices through talks, tutorials, and hands-on sessions that help you deepen your Python skills and build confidence.</p>
</li>
<li>
<p><strong>Community involvement</strong>: Meet other Python users in person, connect with open-source contributors and maintainers, and experience the collaborative culture that defines the Python community.</p>
</li>
<li>
<p><strong>Professional opportunities</strong>: Discover potential job openings, meet companies using Python across industries, and form professional connections that can lead to future projects or roles.</p>
</li>
</ul>
<p>The following sections explore each category in more detail to help you recognize what matters most to you when choosing a Python conference.</p>
<h3 id="personal-growth">Personal Growth<a class="headerlink" href="#personal-growth" title="Permanent link"></a></h3>
<p>One of the biggest benefits of attending a Python conference is the opportunity for personal growth through active learning and engagement.</p>
<p>Python conferences are organized around a program of <strong>talks</strong>, <strong>tutorials</strong>, and <strong>collaborative sessions</strong> that expose you to new ideas, tools, and ways of thinking about Python. The number of program items can range from one at local meetups to over one hundred at larger conferences like <a href="https://realpython.com/pycon-guide/">PyCon US</a> and <a href="https://ep2026.europython.eu">EuroPython</a>.</p>
<p>At larger events, you’re exposed to a wide breadth of topics to choose from, while at smaller events, you have fewer options but can usually attend <em>all</em> the sessions you’re interested in. <strong>Conference talks</strong> are an excellent opportunity to get exposed to new ideas, hear about new tools, or just listen to someone else talk about a topic you’re familiar with, which can be a very educational experience!</p>
<p>Most of these talks are later shared on <a href="https://www.youtube.com/watch?v=iURLDirfmno">YouTube</a>, but attending in person allows you to participate in live Q&A sessions where speakers answer audience questions directly. You also have the chance to meet the speaker after the talk and ask follow-up questions that wouldn’t be possible when watching a recording.</p>
<p><a href="https://pycon-archive.python.org/2025/schedule/tutorials/">Tutorials</a>, on the other hand, are rarely recorded. They tend to be longer than talks and focus on <strong>hands-on coding</strong>, making them a brilliant way to gain practical, working knowledge of a Python feature or tool. Working through exercises with peers and asking questions in real time can help solidify your understanding of a topic.</p>
<p>Some conferences also include <strong>collaborative</strong> <a href="https://pycon-archive.python.org/2025/events/dev-sprints/">sprint events</a>, where you get together with other attendees to contribute to open-source projects, typically with the guidance of the project maintainers themselves:</p>
<figure class="js-lightbox"><a href="https://files.realpython.com/media/europython2023-sprints.e5f567c2e6f8.jpg" target="_blank"><img loading="lazy" class="img-fluid mx-auto d-block " src="https://files.realpython.com/media/europython2023-sprints.e5f567c2e6f8.jpg" width="1920" height="1280" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/europython2023-sprints.e5f567c2e6f8.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/europython2023-sprints.e5f567c2e6f8.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/europython2023-sprints.e5f567c2e6f8.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/europython2023-sprints.e5f567c2e6f8.jpg 1920w" sizes="(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)" alt="EuroPython 2023 attendees during sprints event" data-asset="6759"></a><figcaption class="figure-caption text-center">EuroPython Attendees Collaborating During the Sprints (Image: <a href="https://www.flickr.com/photos/europython/53132660870/in/album-72177720310704011" target="_blank">Braulio Lara</a>)</figcaption></figure>
<p>Participating in sprints under the mentorship of the project maintainers is a great way to boost your confidence in your skills and get some open-source contributions under your belt. </p>
<h3 id="community-involvement">Community Involvement<a class="headerlink" href="#community-involvement" title="Permanent link"></a></h3>
<p>Developers are used to collaborating on open-source projects with people around the world, but working together online isn’t the same as having a face-to-face conversation. Python conferences fill that gap by giving developers a dedicated space to meet and connect in person.</p>
</div><h2><a href="https://realpython.com/python-conference-guide/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/python-conference-guide/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Getting Started With Google Gemini CLIhttps://realpython.com/courses/getting-started-google-gemini-cli/2026-02-03T14:00:00+00:00Learn how to use Gemini CLI to bring Google's AI-powered coding assistance into your terminal for faster code analysis, debugging, and fixes.
<p>This video course will teach you how to use <a href="/ref/ai-coding-tools/gemini-cli/" class="ref-link">Gemini CLI</a> to bring Google’s AI-powered coding assistance directly into your terminal. After you authenticate with your Google account, this tool will be ready to help you analyze code, identify bugs, and suggest fixes—all without leaving your familiar development environment.</p>
<p>Imagine <a href="/ref/glossary/debugging/" class="ref-link">debugging</a> code without switching between your <a href="/ref/glossary/console/" class="ref-link">console</a> and browser, or picture getting instant explanations for unfamiliar projects. Like other command-line AI assistants, Google’s Gemini CLI brings AI-powered coding assistance directly into your command line, allowing you to stay focused in your development workflow.</p>
<p>Whether you’re troubleshooting a stubborn bug, understanding legacy code, or generating documentation, this tool acts as an intelligent pair-programming partner that understands your codebase’s context.</p>
<p>You’re about to install Gemini CLI, authenticate with Google’s free tier, and put it to work on an actual Python project. You’ll discover how natural language queries can help you understand code faster and catch bugs that might slip past manual review.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Terminal: First Steps and Useful Commands for Python Developershttps://realpython.com/terminal-commands/2026-02-02T14:00:00+00:00Learn your way around the Python terminal. You’ll practice basic commands, activate virtual environments, install packages with pip, and keep track of your code using Git.
<div><p>The terminal provides Python developers with direct control over their operating system through text commands. Instead of clicking through menus, you type commands to navigate folders, run scripts, install packages, and manage version control. This command-line approach is faster and more flexible than graphical interfaces for many development tasks.</p>
<p><strong>By the end of this tutorial, you’ll understand that:</strong></p>
<ul>
<li><strong>Terminal commands</strong> like <code>cd</code>, <code>ls</code>, and <code>mkdir</code> let you navigate and organize your file system efficiently</li>
<li><strong>Virtual environments</strong> isolate project dependencies, keeping your Python installations clean and manageable</li>
<li><strong><code>pip</code></strong> installs, updates, and removes Python packages directly from the command line</li>
<li><strong>Git commands</strong> track changes to your code and create snapshots called commits</li>
<li>The <strong>command prompt</strong> displays your current directory and indicates when the terminal is ready for input</li>
</ul>
<p>This tutorial walks through the fundamentals of terminal usage on Windows, Linux, and macOS. The examples cover file system navigation, creating files and folders, managing packages with <code>pip</code>, and tracking code changes with Git.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your Cheat Sheet:</strong> <a href="https://realpython.com/bonus/terminal-commands-cheat-sheet/" class="alert-link" data-toggle="modal" data-target="#modal-terminal-commands-cheat-sheet" markdown>Click here to download a free cheat sheet</a> of useful commands to get you started working with the terminal.</p>
</div>
<h2 id="install-and-open-the-terminal">Install and Open the Terminal<a class="headerlink" href="#install-and-open-the-terminal" title="Permanent link"></a></h2>
<p>Back in the day, the term <em>terminal</em> referred to <a href="https://en.wikipedia.org/wiki/Computer_terminal">some clunky hardware</a> that you used to enter data into a computer.
Nowadays, people are usually talking about a <a href="https://en.wikipedia.org/wiki/terminal_emulator">terminal emulator</a> when they say <strong>terminal</strong>, and they mean some kind of terminal software that you can find on most modern computers. </p>
<div class="alert alert-primary" role="alert">
<p><strong>Note:</strong> There are two other terms that you might hear now and then in combination with the terminal:</p>
<ol>
<li>A <strong>shell</strong> is the program that you interact with when running commands in a terminal.</li>
<li>A <strong>command-line interface (CLI)</strong> is a program designed to run in a shell inside the terminal.</li>
</ol>
<p>In other words, the shell provides the commands that you use in a command-line interface, and the terminal is the application that you run to access the shell.</p>
</div>
<p>If you’re using a Linux or macOS machine, then the terminal is already built in.
You can start using it right away.</p>
<p>On Windows, you also have access to command-line applications like the <a href="https://en.wikipedia.org/wiki/Cmd.exe">Command Prompt</a>.
However, for this tutorial and terminal work in general, you should use the Windows terminal application instead. </p>
<p>Read on to learn how to install and open the terminal on Windows and how to find the terminal on Linux and macOS.</p>
<h3 id="windows">Windows<a class="headerlink" href="#windows" title="Permanent link"></a></h3>
<p>The <strong>Windows terminal</strong> is a modern and feature-rich application that gives you access to the command line, multiple shells, and advanced customization options.
If you have Windows 11 or above, chances are that the Windows terminal is already present on your machine.
Otherwise, you can download the application from the <a href="https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701">Microsoft Store</a> or from the official <a href="https://github.com/microsoft/terminal">GitHub repository</a>.</p>
<p>Before continuing with this tutorial, you need to get the terminal working on your Windows computer.
You can follow the <a href="https://realpython.com/python-coding-setup-windows/">Your Python Coding Environment on Windows: Setup Guide</a> to learn <a href="https://realpython.com/python-coding-setup-windows/#installing-windows-terminal">how to install the Windows terminal</a>.</p>
<p>After you install the Windows terminal, you can find it in the Start menu under <em>Terminal</em>.
When you start the application, you should see a window that looks like this:</p>
<figure class="js-lightbox"><a href="https://files.realpython.com/media/win-10-setup-14-windows-powershell_-_cropped.f114376b1071.png" target="_blank"><img loading="lazy" class="img-fluid mx-auto d-block " src="https://files.realpython.com/media/win-10-setup-14-windows-powershell_-_cropped.f114376b1071.png" width="1024" height="726" srcset="/cdn-cgi/image/width=256,format=auto/https://files.realpython.com/media/win-10-setup-14-windows-powershell_-_cropped.f114376b1071.png 256w, /cdn-cgi/image/width=341,format=auto/https://files.realpython.com/media/win-10-setup-14-windows-powershell_-_cropped.f114376b1071.png 341w, /cdn-cgi/image/width=512,format=auto/https://files.realpython.com/media/win-10-setup-14-windows-powershell_-_cropped.f114376b1071.png 512w, /cdn-cgi/image/width=1024,format=auto/https://files.realpython.com/media/win-10-setup-14-windows-powershell_-_cropped.f114376b1071.png 1024w" sizes="(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)" alt="Windows Terminal with Windows PowerShell tab" data-asset="4454"></a></figure>
<p>It can be handy to create a desktop shortcut for the terminal or pin the application to your task bar for easier access.</p>
<h3 id="linux">Linux<a class="headerlink" href="#linux" title="Permanent link"></a></h3>
<p>You can find the terminal application in the application menu of your Linux distribution.
Alternatively, you can press <span class="keys"><kbd class="key-control">Ctrl</kbd><span>+</span><kbd class="key-alt">Alt</kbd><span>+</span><kbd class="key-t">T</kbd></span> on your keyboard or use the application launcher and search for the word <em>Terminal</em>.</p>
<p>After opening the terminal, you should see a window similar to the screenshot below:</p>
<figure class="js-lightbox"><a href="https://files.realpython.com/media/linux-terminal.28e537154512.png" target="_blank"><img loading="lazy" class="img-fluid mx-auto d-block " src="https://files.realpython.com/media/linux-terminal.28e537154512.png" width="1186" height="701" srcset="/cdn-cgi/image/width=296,format=auto/https://files.realpython.com/media/linux-terminal.28e537154512.png 296w, /cdn-cgi/image/width=395,format=auto/https://files.realpython.com/media/linux-terminal.28e537154512.png 395w, /cdn-cgi/image/width=593,format=auto/https://files.realpython.com/media/linux-terminal.28e537154512.png 593w, /cdn-cgi/image/width=1186,format=auto/https://files.realpython.com/media/linux-terminal.28e537154512.png 1186w" sizes="(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)" alt="Screenshot of the Linux terminal" data-asset="4775"></a></figure>
<p>How you open the terminal may also depend on which Linux distribution you’re using. Each one has a different way of doing it.
If you have trouble opening the terminal on Linux, then the Real Python community will help you out in the comments below.</p>
<h3 id="macos">macOS<a class="headerlink" href="#macos" title="Permanent link"></a></h3>
<p>A common way to open the terminal application on macOS is by opening the <a href="https://support.apple.com/en-us/guide/mac-help/mchlp1008/mac">Spotlight Search</a> and searching for <em>Terminal</em>.
You can also find the terminal app in the application folder inside Finder.</p>
<p>When you open the terminal, you see a window that looks similar to the image below:</p>
</div><h2><a href="https://realpython.com/terminal-commands/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/terminal-commands/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #282: Testing Python Code for Scalability & What's New in pandas 3.0https://realpython.com/podcasts/rpp/282/2026-01-30T12:00:00+00:00How do you create automated tests to check your code for degraded performance as data sizes increase? What are the new features in pandas 3.0? Christopher Trudeau is back on the show this week with another batch of PyCoder's Weekly articles and projects.
<p>How do you create automated tests to check your code for degraded performance as data sizes increase? What are the new features in pandas 3.0? Christopher Trudeau is back on the show this week with another batch of PyCoder's Weekly articles and projects.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
How Long Does It Take to Learn Python?https://realpython.com/how-long-does-it-take-to-learn-python/2026-01-28T14:00:00+00:00This guide breaks down how long it takes to learn Python with realistic timelines, weekly study plans, and strategies to speed up your progress.
<div><p>Have you read blog posts that claim you can learn Python in <em>days</em> and quickly secure a high-paying developer job? That’s an unlikely scenario and doesn’t help you prepare for a steady learning marathon. So, how long does it <em>really</em> take to learn Python, and is it worth your time investment?</p>
<p><strong>By the end of this guide, you’ll understand that:</strong></p>
<ul>
<li>Most beginners can learn core <strong>Python fundamentals in about 2 to 6 months</strong> with consistent practice.</li>
<li>You can write a tiny script in days or weeks, but real confidence comes from <strong>projects and feedback</strong>.</li>
<li>Becoming <strong>job-ready</strong> often takes <strong>6 to 12 months</strong>, depending on your background and target role.</li>
<li><strong>Mastery takes years</strong> because the ecosystem and specializations keep growing.</li>
</ul>
<p>The short answer for how long it takes to learn Python depends on your goals, time budget, and the level you’re aiming for.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get the PDF Guide:</strong> <a href="https://realpython.com/bonus/how-long-does-it-take-to-learn-python-cheatsheet/" class="alert-link" data-toggle="modal" data-target="#modal-how-long-does-it-take-to-learn-python-cheatsheet" markdown>Click here to download</a> a free PDF guide that breaks down how long it takes to learn Python and what factors affect your timeline.</p>
</div>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “Python Skill Test” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/python-skill-test/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #f2f2f2;" alt="Real Python Quizzes" src="https://files.realpython.com/media/Real-Python-Quizzes-Page_Watermarked.0a38006fcf1a.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Real-Python-Quizzes-Page_Watermarked.0a38006fcf1a.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Real-Python-Quizzes-Page_Watermarked.0a38006fcf1a.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Real-Python-Quizzes-Page_Watermarked.0a38006fcf1a.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Real-Python-Quizzes-Page_Watermarked.0a38006fcf1a.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/python-skill-test/" class="stretched-link"><span class="my-0 h4">Python Skill Test</span></a>
<p class="text-muted mb-0 small">Test your Python knowledge in a skills quiz with basic to advanced questions. Are you a Novice, Intermediate, Proficient, or Expert?</p>
</div>
</div>
</div>
<h2 id="how-long-does-it-take-to-learn-python-basics">How Long Does It Take to Learn Python Basics?<a class="headerlink" href="#how-long-does-it-take-to-learn-python-basics" title="Permanent link"></a></h2>
<p>Python is beginner-friendly, and you can start writing simple programs in just a few days. But reaching the <em>basics</em> stage still takes consistent practice because you’re learning both the language itself and how to think like a programmer.</p>
<p>The following timeline shows how long it typically takes to learn Python basics based on how much time you can practice each week:</p>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Weekly practice time</th>
<th>Typical timeline for basics</th>
<th>What that feels like</th>
</tr>
</thead>
<tbody>
<tr>
<td>2–3 hours/week</td>
<td>8–12 months</td>
<td>Slow but steady progress</td>
</tr>
<tr>
<td>5–10 hours/week</td>
<td>3–6 months</td>
<td>Realistic pace for busy adults</td>
</tr>
<tr>
<td>15–20 hours/week</td>
<td>~2 months</td>
<td>Consistent focus and fast feedback</td>
</tr>
<tr>
<td>40+ hours/week</td>
<td>~1 month</td>
<td>Full-time immersion</td>
</tr>
</tbody>
</table>
</div>
<p>These ranges assume about <strong>five study days per week</strong>. If you add a sixth day, you’ll likely land toward the faster end of each range.</p>
<p>You’ll get better results if you use this table as a planning guide. Don’t think of it as rigid deadlines—your learning pace depends on <a href="#what-factors-influence-your-learning-speed">many factors</a>. For example, if you already know another programming language, then you can usually move faster. If you’re brand-new to coding, then expect to be at the slower end of each range.</p>
<p>As a general guideline, many beginners reach the basics in about 2 to 6 months with steady practice.</p>
<div class="alert alert-primary" role="alert">
<p><strong>Note:</strong> If you’re ready to fast-track your learning with an expert-guided small cohort course that gives you live guidance and accountability, then check out <a href="https://realpython.com/live/">Real Python’s live courses</a>!</p>
</div>
<p>With a focused schedule of around four hours per day, five days per week, you can often reach the basics stage in roughly 6 to 10 weeks, assuming you’re writing and debugging code most sessions. By then, you should be able to finish several small projects on your own.</p>
<p>When you read online that someone learned Python quickly, they’re probably talking about this basics stage. And indeed, with the right mix of dedication, circumstances, and practice, learning Python basics can happen pretty fast!</p>
<p>Before you go ahead and lock in a timeline, take a moment to clarify for yourself <em>why</em> you want to learn Python. Understanding your motivation for learning Python will help along the way.</p>
<div class="card mb-3" id="collapse_card811377">
<div class="card-header border-0">
<p class="m-0">
<button class="btn w-100" data-toggle="collapse" data-target="#collapse811377" aria-expanded="false" aria-controls="collapse811377" markdown="1"><span class="float-left" markdown="1">What Does "Learning Python" Even Mean?</span><span class="float-right text-muted">Show/Hide</span></button>
</p>
</div>
<div class="collapse js-collapsible-section" data-parent="#collapse_card811377" id="collapse811377">
<div class="card-body">
<p>Learning Python means <em>more</em> than just learning the Python programming language. You need to know more than just the specifics of a single programming language to <strong>do something useful with your programming skills</strong>. At the same time, you don’t need to understand every single aspect of Python to be productive.</p>
<p>Learning Python is about learning how to accomplish practical tasks with Python programming. It’s about having a skill set that you can use to build projects for yourself or an employer.</p>
</div>
</div>
</div>
<p>As your next step, write down your personal goal for learning Python. Always keep that goal in mind throughout your learning journey. Your goal shapes what you need to learn and how quickly you’ll progress.</p>
<h2 id="whats-a-practical-30-day-learning-plan-for-complete-beginners">What’s a Practical 30-Day Learning Plan for Complete Beginners?<a class="headerlink" href="#whats-a-practical-30-day-learning-plan-for-complete-beginners" title="Permanent link"></a></h2>
<p>When you’re clear about your <em>why</em>, you can start drafting your personal <a href="https://realpython.com/build-python-learning-roadmap/">Python learning roadmap</a>.</p>
<p>If you’re starting from zero and can spend about 5 to 10 hours per week, the following plan keeps you moving without becoming overwhelming:</p>
<ul>
<li><strong>Week 1</strong>: <a href="https://realpython.com/installing-python/">Install</a> and <a href="https://realpython.com/python-coding-setup-windows/">set up</a> Python, learn about <a href="https://realpython.com/python-first-steps/">basic syntax</a>, <a href="https://realpython.com/python-variables/">variables</a>, and <a href="https://realpython.com/python-conditional-statements/">conditional statements</a></li>
<li><strong>Week 2</strong>: Learn about <a href="https://realpython.com/python-data-types/">basic data types</a>, <a href="https://realpython.com/python-for-loop/"><code>for</code></a> and <a href="https://realpython.com/python-while-loop/"><code>while</code> loops</a>, and <a href="https://realpython.com/defining-your-own-python-function/">functions</a></li>
<li><strong>Week 3</strong>: Work with <a href="https://realpython.com/python-list/">lists</a> and <a href="https://realpython.com/python-dicts/">dictionaries</a>, <a href="https://realpython.com/working-with-files-in-python/">file I/O</a>, and <a href="https://realpython.com/python-debug-idle/">debugging basics</a></li>
<li><strong>Week 4</strong>: Build a small <a href="https://realpython.com/tutorials/projects/">project</a>, add simple <a href="https://realpython.com/python-testing/">tests</a>, and polish it through <a href="https://realpython.com/python-refactoring/">refactoring</a></li>
</ul>
<p>Aim to finish at least one small project by the end of the month. The project matters more than completing every tutorial or task on your checklist.</p>
</div><h2><a href="https://realpython.com/how-long-does-it-take-to-learn-python/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/how-long-does-it-take-to-learn-python/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Create Callable Instances With Python's .__call__()https://realpython.com/courses/create-callable-instances-dunder-call/2026-01-27T14:00:00+00:00Learn Python callables: what "callable" means, how to use dunder call, and how to build callable objects with step-by-step examples.
<p>In Python, a <strong>callable</strong> is any object that you can call using a pair of parentheses and, optionally, a series of arguments. Functions, classes, and methods are all common examples of callables in Python. Besides these, you can also create custom classes that produce <strong>callable instances</strong>. To do this, you can add the <strong><code>.__call__()</code></strong> special method to your class.</p>
<p>Instances of a class with a <code>.__call__()</code> method behave like functions, providing a flexible and handy way to add functionality to your objects. Understanding how to create and use callable instances is a valuable skill for any Python developer.</p>
<p><strong>In this video course, you’ll:</strong></p>
<ul>
<li>Understand the concept of <strong>callable objects</strong> in Python</li>
<li>Create <strong>callable instances</strong> by adding a <strong><code>.__call__()</code></strong> method to your classes </li>
<li>Compare <strong><code>.__init__()</code></strong> and <strong><code>.__call__()</code></strong> and understand their distinct roles</li>
<li>Build practical examples that use callable instances to <strong>solve real-world problems</strong></li>
</ul>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
GeoPandas Basics: Maps, Projections, and Spatial Joinshttps://realpython.com/geopandas/2026-01-26T14:00:00+00:00Dive into GeoPandas with this tutorial covering data loading, mapping, CRS concepts, projections, and spatial joins for intuitive analysis.
<div><p>GeoPandas extends pandas to make working with geospatial data in Python intuitive and powerful. If you’re looking to do geospatial tasks in Python and want a library with a pandas-like API, then GeoPandas is an excellent choice. This tutorial shows you how to accomplish four common geospatial tasks: reading in data, mapping it, applying a projection, and doing a spatial join.</p>
<p><strong>By the end of this tutorial, you’ll understand that:</strong></p>
<ul>
<li><strong>GeoPandas extends pandas</strong> with support for spatial data. This data typically lives in a <code>geometry</code> column and allows <strong>spatial operations</strong> such as projections and spatial joins, while <strong>Folium</strong> focuses on richer interactive web maps after data preparation.</li>
<li>You <strong>inspect CRS</strong> with <code>.crs</code> and <strong>reproject</strong> data using <code>.to_crs()</code> with an authority code like <code>EPSG:4326</code> or <code>ESRI:54009</code>.</li>
<li>A <strong>geographic CRS</strong> stores longitude and latitude in degrees, while a <strong>projected CRS</strong> uses linear units like meters or feet for area and distance calculations.</li>
<li>Spatial joins use <code>.sjoin()</code> with predicates like <code>"within"</code> or <code>"intersects"</code>, and <strong>both inputs must share the same CRS</strong> or the relationships will be computed incorrectly.</li>
</ul>
<p>Here’s how GeoPandas compares with alternative libraries:</p>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Use Case</th>
<th>Pick pandas</th>
<th>Pick Folium</th>
<th>Pick GeoPandas</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tabular data analysis</td>
<td>✅</td>
<td>-</td>
<td>✅</td>
</tr>
<tr>
<td>Mapping</td>
<td>-</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>Projections, spatial joins</td>
<td>-</td>
<td>-</td>
<td>✅</td>
</tr>
</tbody>
</table>
</div>
<p>GeoPandas builds on pandas by adding support for geospatial data and operations like <a href="https://en.wikipedia.org/wiki/Map_projection">projections</a> and <a href="https://en.wikipedia.org/wiki/Spatial_join">spatial joins</a>. It also includes tools for creating maps. <a href="https://realpython.com/python-folium-web-maps-from-data/">Folium</a> complements this by focusing on interactive, web-based maps that you can customize more deeply.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your Code:</strong> <a href="https://realpython.com/bonus/geopandas-code/" class="alert-link" data-toggle="modal" data-target="#modal-geopandas-code" markdown>Click here to download the free sample code</a> for learning how to work with GeoPandas maps, projections, and spatial joins.</p>
</div>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “GeoPandas Basics: Maps, Projections, and Spatial Joins” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/geopandas/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #abe0e6;" alt="GeoPandas Basics: Maps, Projections, and Spatial Joins" src="https://files.realpython.com/media/GeoPandas-for-Geospatial-Analysis-Spatial-Joins-Projections-and-Quick-Maps_Watermarked.1bd7d02f55cb.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/GeoPandas-for-Geospatial-Analysis-Spatial-Joins-Projections-and-Quick-Maps_Watermarked.1bd7d02f55cb.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/GeoPandas-for-Geospatial-Analysis-Spatial-Joins-Projections-and-Quick-Maps_Watermarked.1bd7d02f55cb.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/GeoPandas-for-Geospatial-Analysis-Spatial-Joins-Projections-and-Quick-Maps_Watermarked.1bd7d02f55cb.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/GeoPandas-for-Geospatial-Analysis-Spatial-Joins-Projections-and-Quick-Maps_Watermarked.1bd7d02f55cb.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/geopandas/" class="stretched-link"><span class="my-0 h4">GeoPandas Basics: Maps, Projections, and Spatial Joins</span></a>
<p class="text-muted mb-0 small">Test GeoPandas basics for reading, mapping, projecting, and spatial joins to handle geospatial data confidently.</p>
</div>
</div>
</div>
<h2 id="getting-started-with-geopandas">Getting Started With GeoPandas<a class="headerlink" href="#getting-started-with-geopandas" title="Permanent link"></a></h2>
<p>You’ll first prepare your environment and load a small dataset that you’ll use throughout the tutorial. In the next two subsections, you’ll install the necessary packages and read in a sample dataset of New York City borough boundaries. This gives you a concrete GeoDataFrame to explore as you learn the core concepts.</p>
<h3 id="installing-geopandas">Installing GeoPandas<a class="headerlink" href="#installing-geopandas" title="Permanent link"></a></h3>
<p>This tutorial uses two packages: <code>geopandas</code> for working with geographic data and <code>geodatasets</code> for loading sample data. It’s a good idea to install these packages inside a <a href="https://realpython.com/python-virtual-environments-a-primer/">virtual environment</a> so your project stays isolated from the rest of your system and you can manage its <a href="/ref/glossary/dependency/" class="ref-link">dependencies</a> cleanly. </p>
<p>Once your virtual environment is active, you can <a href="https://realpython.com/what-is-pip/">install both packages with <code>pip</code></a>:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span><span class="s2">"geopandas[all]"</span><span class="w"> </span>geodatasets
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>Using the <code>[all]</code> option ensures you have everything needed for reading data, transforming coordinate systems, and creating plots. For most readers, this will work out of the box.</p>
<p>If you do run into installation issues, the project’s maintainers provide alternative installation options on the <a href="https://geopandas.org/en/stable/getting_started/install.html">official installation page</a>.</p>
<h3 id="reading-in-data">Reading in Data<a class="headerlink" href="#reading-in-data" title="Permanent link"></a></h3>
<p>Most geospatial datasets come in <a href="https://en.wikipedia.org/wiki/GeoJSON">GeoJSON</a> or <a href="https://en.wikipedia.org/wiki/Shapefile">shapefile</a> format. The <code>read_file()</code> function can read both, and it accepts either a local file path or a URL.</p>
<p>In the example below, you’ll use <code>read_file()</code> to load the New York City Borough Boundaries (NYBB) dataset. The <code>geodatasets</code> package provides a convenient path to this dataset, so you don’t need to download anything manually. You’ll also drop unnecessary columns:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="pycon" data-is-repl="true">
<div class="codeblock__header codeblock--blue">
<span class="mr-2 noselect" aria-label="Language">Python</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">geopandas</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">gpd</span>
<span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span>
<span class="gp">>>> </span><span class="kn">from</span><span class="w"> </span><span class="nn">geodatasets</span><span class="w"> </span><span class="kn">import</span> <span class="n">get_path</span>
<span class="gp">>>> </span><span class="n">path_to_data</span> <span class="o">=</span> <span class="n">get_path</span><span class="p">(</span><span class="s2">"nybb"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">nybb</span> <span class="o">=</span> <span class="n">gpd</span><span class="o">.</span><span class="n">read_file</span><span class="p">(</span><span class="n">path_to_data</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">nybb</span> <span class="o">=</span> <span class="n">nybb</span><span class="p">[[</span><span class="s2">"BoroName"</span><span class="p">,</span> <span class="s2">"Shape_Area"</span><span class="p">,</span> <span class="s2">"geometry"</span><span class="p">]]</span>
<span class="gp">>>> </span><span class="n">nybb</span>
<span class="go"> BoroName Shape_Area geometry</span>
<span class="go">0 Staten Island 1.623820e+09 MULTIPOLYGON (((970217.022 145643.332, ....</span>
<span class="go">1 Queens 3.045213e+09 MULTIPOLYGON (((1029606.077 156073.814, ...</span>
<span class="go">2 Brooklyn 1.937479e+09 MULTIPOLYGON (((1021176.479 151374.797, ...</span>
<span class="go">3 Manhattan 6.364715e+08 MULTIPOLYGON (((981219.056 188655.316, ....</span>
<span class="go">4 Bronx 1.186925e+09 MULTIPOLYGON (((1012821.806 229228.265, ...</span>
<span class="gp">>>> </span><span class="nb">type</span><span class="p">(</span><span class="n">nybb</span><span class="p">)</span>
<span class="go"><class 'geopandas.geodataframe.GeoDataFrame'></span>
<span class="gp">>>> </span><span class="nb">type</span><span class="p">(</span><span class="n">nybb</span><span class="p">[</span><span class="s2">"geometry"</span><span class="p">])</span>
<span class="go"><class 'geopandas.geoseries.GeoSeries'></span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p><code>nybb</code> is a <strong>GeoDataFrame</strong>. A GeoDataFrame has rows, columns, and all the methods of a <a href="https://realpython.com/pandas-dataframe/">pandas DataFrame</a>. The difference is that it typically includes a special <code>geometry</code> column, which stores geographic shapes instead of plain numbers or text.</p>
<p>The <code>geometry</code> column is a <code>GeoSeries</code>. It behaves like a normal pandas <code>Series</code>, but its values are spatial objects that you can map and run spatial queries against. In the <code>nybb</code> dataset, each borough’s geometry is a <code>MultiPolygon</code>—a shape made of several polygons—because every borough consists of multiple islands. Soon you’ll use these geometries to make maps and run spatial operations, such as finding which borough a point falls inside.</p>
<h2 id="mapping-data">Mapping Data<a class="headerlink" href="#mapping-data" title="Permanent link"></a></h2>
<p>Once you’ve loaded a GeoDataFrame, one of the quickest ways to understand your data is to visualize it. In this section, you’ll learn how to create both static and interactive maps. This allows you to inspect shapes, spot patterns, and confirm that your geometries look the way you expect.</p>
<h3 id="creating-static-maps">Creating Static Maps<a class="headerlink" href="#creating-static-maps" title="Permanent link"></a></h3>
</div><h2><a href="https://realpython.com/geopandas/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/geopandas/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: GeoPandas Basics: Maps, Projections, and Spatial Joinshttps://realpython.com/quizzes/geopandas/2026-01-26T12:00:00+00:00Test GeoPandas basics for reading, mapping, projecting, and spatial joins to handle geospatial data confidently.
<p>In this quiz, you’ll test your understanding of <a href="https://realpython.com/geopandas/">GeoPandas</a>.</p>
<p>You’ll review coordinate reference systems, GeoDataFrames, interactive maps, and spatial joins with <code>.sjoin()</code>. You’ll also explore how projections affect maps and learn best practices for working with geospatial data.</p>
<p>This quiz helps you confirm that you can prepare, visualize, and analyze geospatial data accurately using GeoPandas.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #281: Continuing to Improve the Learning Experience at Real Pythonhttps://realpython.com/podcasts/rpp/281/2026-01-23T12:00:00+00:00If you haven't visited the Real Python website lately, then it's time to check out a great batch of updates on realpython.com! Dan Bader returns to the show this week to discuss improvements to the site and more ways to learn Python.
<p>If you haven't visited the Real Python website lately, then it's time to check out a great batch of updates on realpython.com! Dan Bader returns to the show this week to discuss improvements to the site and more ways to learn Python.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
How to Integrate Local LLMs With Ollama and Pythonhttps://realpython.com/ollama-python/2026-01-21T14:00:00+00:00Learn how to integrate your Python projects with local models (LLMs) using Ollama for enhanced privacy and cost efficiency.
<div><p>Integrating local large language models (LLMs) into your Python projects using Ollama is a great strategy for improving privacy, reducing costs, and building offline-capable AI-powered apps.</p>
<p><strong>Ollama</strong> is an open-source platform that makes it straightforward to run modern LLMs locally on your machine. Once you’ve set up Ollama and pulled the models you want to use, you can connect to them from Python using the <code>ollama</code> library.</p>
<p>Here’s a quick demo:</p>
<figure>
<div class="embed-responsive embed-responsive-16by9 rounded mb-3 ">
<iframe loading="lazy" class="embed-responsive-item" src="https://player.vimeo.com/video/1151859183?background=1" frameborder="0" allow="fullscreen" allowfullscreen></iframe>
</div>
</figure>
<p>In this tutorial, you’ll integrate local LLMs into your Python projects using the Ollama platform and its Python SDK.</p>
<p>You’ll first set up Ollama and pull a couple of LLMs. Then, you’ll learn how to use chat, text generation, and tool calling from your Python code. These skills will enable you to build AI-powered apps that run locally, improving privacy and cost efficiency.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your Code:</strong> <a href="https://realpython.com/bonus/ollama-python-code/" class="alert-link" data-toggle="modal" data-target="#modal-ollama-python-code" markdown>Click here to download the free sample code</a> that you’ll use to integrate LLMs With Ollama and Python.</p>
</div>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “How to Integrate Local LLMs With Ollama and Python” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/ollama-python/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #e5c6aa;" alt="How to Integrate Local LLMs With Ollama and Python" src="https://files.realpython.com/media/How-to-Integrate-Local-LLMs-With-Ollama-and-Python_Watermarked.835ee5f2672d.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/How-to-Integrate-Local-LLMs-With-Ollama-and-Python_Watermarked.835ee5f2672d.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Integrate-Local-LLMs-With-Ollama-and-Python_Watermarked.835ee5f2672d.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Integrate-Local-LLMs-With-Ollama-and-Python_Watermarked.835ee5f2672d.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Integrate-Local-LLMs-With-Ollama-and-Python_Watermarked.835ee5f2672d.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/ollama-python/" class="stretched-link"><span class="my-0 h4">How to Integrate Local LLMs With Ollama and Python</span></a>
<p class="text-muted mb-0 small">Check your understanding of using Ollama with Python to run local LLMs, generate text, chat, and call tools for private, offline apps.</p>
</div>
</div>
</div>
<h2 id="prerequisites">Prerequisites<a class="headerlink" href="#prerequisites" title="Permanent link"></a></h2>
<p>To work through this tutorial, you’ll need the following resources and setup:</p>
<ul>
<li><strong>Ollama installed and running</strong>: You’ll need <a href="/ref/ai-coding-tools/ollama/" class="ref-link">Ollama</a> to use local LLMs. You’ll get to install it and set it up in the next section.</li>
<li><strong>Python 3.8 or higher</strong>: You’ll be using Ollama’s Python software development kit (SDK), which requires Python 3.8 or higher. If you haven’t already, <a href="https://realpython.com/installing-python/">install Python</a> on your system to fulfill this requirement.</li>
<li><strong>Models to use</strong>: You’ll use <code>llama3.2:latest</code> and <code>codellama:latest</code> in this tutorial. You’ll download them in the next section.</li>
<li><strong>Capable hardware</strong>: You need relatively powerful hardware to run Ollama’s models locally, as they may require considerable resources, including memory, disk space, and CPU power. You may not need a GPU for this tutorial, but local models will run much faster if you have one.</li>
</ul>
<p>With these prerequisites in place, you’re ready to connect local models to your Python code using Ollama. </p>
<h2 id="step-1-set-up-ollama-models-and-the-python-sdk">Step 1: Set Up Ollama, Models, and the Python SDK<a class="headerlink" href="#step-1-set-up-ollama-models-and-the-python-sdk" title="Permanent link"></a></h2>
<p>Before you can talk to a local model from Python, you need Ollama running and at least one model downloaded. In this step, you’ll install Ollama, start its background service, and pull the models you’ll use throughout the tutorial.</p>
<h3 id="get-ollama-running">Get Ollama Running<a class="headerlink" href="#get-ollama-running" title="Permanent link"></a></h3>
<p>To get started, navigate to Ollama’s <a href="https://ollama.com/download">download page</a> and grab the installer for your current operating system. You’ll find installers for Windows 10 or newer and macOS 14 Sonoma or newer. Run the appropriate installer and follow the on-screen instructions. For Linux users, the installation process differs slightly, as you’ll learn soon.</p>
<p>On Windows, Ollama will run in the background after installation, and the CLI will be available for you. If this doesn’t happen automatically for you, then go to the <em>Start</em> menu, search for Ollama, and run the app.</p>
<p>On macOS, the app manages the CLI and setup details, so you just need to launch <em>Ollama.app</em>.</p>
<p>If you’re on Linux, install Ollama with the following command:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span>curl<span class="w"> </span>-fsSL<span class="w"> </span>https://ollama.com/install.sh<span class="w"> </span><span class="p">|</span><span class="w"> </span>sh
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>Once the process is complete, you can verify the installation by running:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span>ollama<span class="w"> </span>-v
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>If this command works, then the installation was successful. Next, start Ollama’s service by running the command below:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span>ollama<span class="w"> </span>serve
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>That’s it! You’re now ready to start using Ollama on your local machine. In some Linux distributions, such as Ubuntu, this final command may not be necessary, as Ollama may start automatically when the installation is complete. In that case, running the command above will result in an error.</p>
</div><h2><a href="https://realpython.com/ollama-python/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/ollama-python/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: How to Integrate Local LLMs With Ollama and Pythonhttps://realpython.com/quizzes/ollama-python/2026-01-21T12:00:00+00:00Check your understanding of using Ollama with Python to run local LLMs, generate text, chat, and call tools for private, offline apps.
<p>In this quiz, you’ll test your understanding of <a href="https://realpython.com/ollama-python/">How to Integrate Local LLMs With Ollama and Python</a>.</p>
<p>By working through this quiz, you’ll revisit how to set up Ollama, pull models, and use chat, text generation, and tool calling from Python.</p>
<p>You’ll connect to local models through the <code>ollama</code> Python library and practice sending prompts and handling responses. You’ll also see how local inference can improve privacy and cost efficiency while keeping your apps offline-capable.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
uv vs pip: Python Packaging and Dependency Managementhttps://realpython.com/courses/uv-vs-pip-packaging-dependency-management/2026-01-20T14:00:00+00:00Choosing between uv vs pip? This video course compares speed, reproducible environments, compatibility, and dependency management to help you pick the right tool.
<p>When it comes to Python package managers, the choice often comes down to <code>uv</code> vs <code>pip</code>. You may choose <code>pip</code> for out-of-the-box availability, broad compatibility, and reliable ecosystem support. In contrast, <code>uv</code> is worth considering if you prioritize fast installs, reproducible environments, and clean uninstall behavior, or if you want to streamline workflows for new projects.</p>
<p>In this video course, you’ll compare both tools. To keep this comparison meaningful, you’ll focus on the overlapping features, primarily <em>package installation</em> and <em>dependency management</em>.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
How to Integrate ChatGPT's API With Python Projectshttps://realpython.com/chatgpt-api-python/2026-01-19T14:00:00+00:00Learn how to use the ChatGPT Python API with the openai library to build AI-powered features in your Python applications.
<div><p>Python’s <code>openai</code> library provides the tools you need to integrate the ChatGPT API into your Python applications. With it, you can send text prompts to the API and receive AI-generated responses. You can also guide the AI’s behavior with <code>developer</code> role messages and handle both simple text generation and more complex code creation tasks. Here’s an example:</p>
<figure class="js-lightbox"><a href="https://files.realpython.com/media/python_coding_assistant_output.a6e05c3f37e4.png" target="_blank"><img loading="lazy" class="img-fluid mx-auto d-block " src="https://files.realpython.com/media/python_coding_assistant_output.a6e05c3f37e4.png" width="1920" height="618" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/python_coding_assistant_output.a6e05c3f37e4.png 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/python_coding_assistant_output.a6e05c3f37e4.png 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/python_coding_assistant_output.a6e05c3f37e4.png 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/python_coding_assistant_output.a6e05c3f37e4.png 1920w" sizes="(min-width: 1200px) 690px, (min-width: 780px) calc(-5vw + 669px), (min-width: 580px) 510px, calc(100vw - 30px)" alt="ChatGPT Python API Example" data-asset="6698"></a><figcaption class="figure-caption text-center">Python Script Output from a ChatGPT API Call Using openai</figcaption></figure>
<p>After reading this tutorial, you’ll understand how examples like this work under the hood. You’ll learn the fundamentals of using the <a href="/ref/ai-coding-tools/chatgpt/" class="ref-link">ChatGPT</a> <a href="/ref/glossary/api/" class="ref-link">API</a> from Python and have code examples you can adapt for your own projects.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your Code:</strong> <a href="https://realpython.com/bonus/chatgpt-python-api-code/" class="alert-link" data-toggle="modal" data-target="#modal-chatgpt-python-api-code" markdown>Click here to download the free sample code</a> that you’ll use to integrate ChatGPT’s API with Python projects.</p>
</div>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “How to Integrate ChatGPT's API With Python Projects” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/chatgpt-api-python/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #ffc973;" alt="How to Integrate ChatGPT's API With Python Projects" src="https://files.realpython.com/media/How-to-Integrate-ChatGPTs-API-with-Python-Projects_Watermarked.043c1909a080.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/How-to-Integrate-ChatGPTs-API-with-Python-Projects_Watermarked.043c1909a080.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/How-to-Integrate-ChatGPTs-API-with-Python-Projects_Watermarked.043c1909a080.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/How-to-Integrate-ChatGPTs-API-with-Python-Projects_Watermarked.043c1909a080.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/How-to-Integrate-ChatGPTs-API-with-Python-Projects_Watermarked.043c1909a080.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/chatgpt-api-python/" class="stretched-link"><span class="my-0 h4">How to Integrate ChatGPT's API With Python Projects</span></a>
<p class="text-muted mb-0 small">Test your knowledge of the ChatGPT API in Python. Practice sending prompts with openai and handling text and code responses in this quick quiz.</p>
</div>
</div>
</div>
<h2 id="prerequisites">Prerequisites<a class="headerlink" href="#prerequisites" title="Permanent link"></a></h2>
<p>To follow along with this tutorial, you’ll need the following:</p>
<ul>
<li><strong>Python Knowledge:</strong> You should be familiar with Python concepts like <a href="https://realpython.com/defining-your-own-python-function/">functions</a>, <a href="https://realpython.com/run-python-scripts/">executing Python scripts</a>, and <a href="https://realpython.com/python-virtual-environments-a-primer/">Python virtual environments</a>.</li>
<li><strong>Python Installation:</strong> You’ll need Python installed on your system. If you haven’t already, <a href="https://realpython.com/installing-python/">install Python</a> on your machine.</li>
<li><strong>OpenAI Account:</strong> An <a href="https://platform.openai.com/">OpenAI account</a> with API access and available credits is required to use the ChatGPT API. You’ll obtain your API key from the OpenAI platform in Step 1.</li>
</ul>
<p>Don’t worry if you’re new to working with APIs. This tutorial will guide you through everything you need to know to get started with the ChatGPT API and implement AI features in your applications.</p>
<h2 id="step-1-obtain-your-api-key-and-install-the-openai-package">Step 1: Obtain Your API Key and Install the OpenAI Package<a class="headerlink" href="#step-1-obtain-your-api-key-and-install-the-openai-package" title="Permanent link"></a></h2>
<p>Before you can start making calls to the ChatGPT Python API, you need to obtain an API key and install the OpenAI Python library. You’ll start by getting your API key from the OpenAI platform, then install the required package and verify that everything works.</p>
<h3 id="obtain-your-api-key">Obtain Your API Key<a class="headerlink" href="#obtain-your-api-key" title="Permanent link"></a></h3>
<p>You can obtain an API key from the OpenAI platform by following these steps:</p>
<ol>
<li>Navigate to <a href="https://platform.openai.com/">platform.openai.com</a> and sign in to your account or create a new one if you don’t have an account yet.</li>
<li>Click on the settings icon in the top-right corner and select <em>API keys</em> from the left-hand menu.</li>
<li>Click the <em>Create new secret key</em> button to generate a new API key.</li>
<li>In the dialog that appears, give your key a descriptive name like “Python Tutorial Key” to help you identify it later.</li>
<li>For the <em>Project</em> field, select your preferred project.</li>
<li>Under <em>Permissions</em>, select <em>All</em> to give your key full access to the API for development purposes.</li>
<li>Click <em>Create secret key</em> to generate your API key.</li>
<li>Copy the generated key immediately, as you won’t be able to see it again after closing the dialog.</li>
</ol>
<p>Now that you have your API key, you need to store it securely.</p>
<div class="alert alert-primary" role="alert">
<p><strong>Warning:</strong> Never hard-code your API key directly in your Python scripts or commit it to version control. Always use environment variables or secure key management services to keep your credentials safe.</p>
</div>
<p>The OpenAI Python library automatically looks for an environment variable named <code>OPENAI_API_KEY</code> when creating a client connection. By setting this variable in your terminal session, you’ll authenticate your API requests without exposing your key in your code.</p>
<p>Set the <code>OPENAI_API_KEY</code> environment variable in your <a href="https://realpython.com/terminal-commands/">terminal</a> session:</p>
<ul class="nav nav-tabs justify-content-end js-platform-widget-tabs" role="tablist">
<li class="nav-item mb-0 js-platform-widget-tab-windows" role="presentation">
<a class="nav-link link-unstyled text-body active small" id="windows-tab-1" data-toggle="tab" href="#windows-1" role="tab" aria-controls="windows-1" aria-selected="true"><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#brands--windows"></use></svg></span>Windows</a>
</li>
<li class="nav-item mb-0 js-platform-widget-tab-linuxmacos" role="presentation">
<a class="nav-link link-unstyled text-body small" id="macos-tab-1" data-toggle="tab" href="#linux-macos-1" role="tab" aria-controls="linux-macos-1" aria-selected="false"><span class="icon baseline text-muted" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--linux"></use></svg></span><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--apple"></use></svg></span>Linux + macOS</a>
</li>
</ul>
<div class="tab-content mt-2 mb-0 js-platform-widget-content">
<div aria-labelledby="windows-tab-1" class="tab-pane fade show active" id="windows-1" role="tabpanel">
<code-block class="mb-3" aria-label="Code block" data-syntax-language="pscon" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Windows PowerShell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">PS> </span><span class="nv">$env:OPENAI_API_KEY</span><span class="p">=</span><span class="s2">"your-api-key-here"</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
</div>
<div aria-labelledby="linux-macos-tab-1" class="tab-pane fade " id="linux-macos-1" role="tabpanel">
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span><span class="nb">export</span><span class="w"> </span><span class="nv">OPENAI_API_KEY</span><span class="o">=</span><span class="s2">"your-api-key-here"</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
</div>
</div>
<p>Replace <code>your-api-key-here</code> with the actual API key you copied from the OpenAI platform.</p>
<h3 id="install-the-openai-package">Install the OpenAI Package<a class="headerlink" href="#install-the-openai-package" title="Permanent link"></a></h3>
<p>With your API key configured, you can now install the OpenAI Python library. The <code>openai</code> package is available on the <a href="/ref/glossary/pypi/" class="ref-link">Python Package Index (PyPI)</a>, and you can install it with <a href="https://realpython.com/what-is-pip/"><code>pip</code></a>.</p>
<p>Open a <a href="https://realpython.com/terminal-commands/">terminal</a> or command prompt, create a new virtual environment, and then install the library:</p>
<ul class="nav nav-tabs justify-content-end js-platform-widget-tabs" role="tablist">
<li class="nav-item mb-0 js-platform-widget-tab-windows" role="presentation">
<a class="nav-link link-unstyled text-body active small" id="windows-tab-2" data-toggle="tab" href="#windows-2" role="tab" aria-controls="windows-2" aria-selected="true"><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#brands--windows"></use></svg></span>Windows</a>
</li>
<li class="nav-item mb-0 js-platform-widget-tab-linuxmacos" role="presentation">
<a class="nav-link link-unstyled text-body small" id="macos-tab-2" data-toggle="tab" href="#linux-macos-2" role="tab" aria-controls="linux-macos-2" aria-selected="false"><span class="icon baseline text-muted" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--linux"></use></svg></span><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--apple"></use></svg></span>Linux + macOS</a>
</li>
</ul>
</div><h2><a href="https://realpython.com/chatgpt-api-python/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/chatgpt-api-python/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: How to Integrate ChatGPT's API With Python Projectshttps://realpython.com/quizzes/chatgpt-api-python/2026-01-19T12:00:00+00:00Test your knowledge of the ChatGPT API in Python. Practice sending prompts with openai and handling text and code responses in this quick quiz.
<p>In this quiz, you’ll test your understanding of <a href="https://realpython.com/chatgpt-api-python/">How to Integrate ChatGPT’s API With Python Projects</a>.</p>
<p>By working through this quiz, you’ll revisit how to send prompts with the <code>openai</code> library, guide behavior with developer role messages, and handle text and code outputs. You’ll also see how to integrate AI responses into your Python scripts for practical tasks.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #280: Considering Fast and Slow in Python Programminghttps://realpython.com/podcasts/rpp/280/2026-01-16T12:00:00+00:00How often have you heard about the speed of Python? What's actually being measured, where are the bottlenecks---development time or run time---and which matters more for productivity? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder's Weekly articles and projects.
<p>How often have you heard about the speed of Python? What's actually being measured, where are the bottlenecks---development time or run time---and which matters more for productivity? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder's Weekly articles and projects.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
How to Create a Django Projecthttps://realpython.com/django-setup/2026-01-14T14:00:00+00:00Learn how to create a Django project and app in clear, guided steps. Use it as a reference for any future Django project and tutorial you'll work on.
<div><p>Before you can start <a href="https://realpython.com/get-started-with-django-1/">building your Django web application</a>, you need to set up your Django project. In this guide you’ll learn how to create a new Django project in four straightforward steps and only six commands:</p>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Step</th>
<th>Description</th>
<th>Command</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#step-1-prepare-your-environment">1a</a></td>
<td>Set up a virtual environment</td>
<td><code>python -m venv .venv</code></td>
</tr>
<tr>
<td><a href="#step-1-prepare-your-environment">1b</a></td>
<td>Activate the virtual environment</td>
<td><code>source .venv/bin/activate</code></td>
</tr>
<tr>
<td><a href="#step-2-install-django-and-pin-your-dependencies">2a</a></td>
<td>Install Django</td>
<td><code>python -m pip install django</code></td>
</tr>
<tr>
<td><a href="#step-2-install-django-and-pin-your-dependencies">2b</a></td>
<td>Pin your dependencies</td>
<td><code>python -m pip freeze > requirements.txt</code></td>
</tr>
<tr>
<td><a href="#step-3-set-up-a-django-project">3</a></td>
<td>Set up a Django project</td>
<td><code>django-admin startproject <projectname></code></td>
</tr>
<tr>
<td><a href="#step-4-start-a-django-app">4</a></td>
<td>Start a Django app</td>
<td><code>python manage.py startapp <appname></code></td>
</tr>
</tbody>
</table>
</div>
<p>The tutorial focuses on the initial steps you’ll always need to start a new web application.</p>
<p>Use this tutorial as your go-to reference until you’ve built so many projects that the necessary commands become second nature. Until then, follow the steps outlined below and in the <a href="#command-reference-how-to-create-a-django-project">command reference</a>, or download the PDF cheatsheet as a printable reference:</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Free Bonus:</strong> <a href="https://realpython.com/bonus/django-project-cheatsheet/" class="alert-link" data-toggle="modal" data-target="#modal-django-project-cheatsheet" markdown>Click here to download the Django Project cheat sheet</a> that assembles all important commands and tips on one page that’s easy to print.</p>
</div>
<p>There are also a few exercises throughout the tutorial to help reinforce what you’re learning, and you can test your knowledge in the associated quiz:</p>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “How to Create a Django Project” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/django-setup/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #abe0e6;" alt="Django Setup Guide" src="https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Django_Setup_Watermark.6c4def7c5b2f.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/django-setup/" class="stretched-link"><span class="my-0 h4">How to Create a Django Project</span></a>
<p class="text-muted mb-0 small">Check your Django setup skills. Install safely and pin requirements, create a project and an app. Start building your first site.</p>
</div>
</div>
</div>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your Code:</strong> <a href="https://realpython.com/bonus/django-setup-code/" class="alert-link" data-toggle="modal" data-target="#modal-django-setup-code" markdown>Click here to download the free sample code</a> that shows you how to create a Django project.</p>
</div>
<h2 id="prerequisites">Prerequisites<a class="headerlink" href="#prerequisites" title="Permanent link"></a></h2>
<p>Before you start creating your <a href="https://www.djangoproject.com/">Django</a> project, make sure you have the right tools and knowledge in place. This tutorial assumes you’re comfortable working with the <a href="/ref/glossary/console/" class="ref-link">command line</a>, but you don’t need to be an expert. Here’s what you’ll need to get started:</p>
<ul>
<li><a href="https://realpython.com/installing-python/">Python 3.12 or higher installed</a> on your system</li>
<li>Basic familiarity with <a href="https://realpython.com/python-virtual-environments-a-primer/">virtual environments</a></li>
<li>Understanding of Python’s package manager, <a href="https://realpython.com/what-is-pip/"><code>pip</code></a></li>
<li>Access to a <a href="https://realpython.com/terminal-commands/">command-line interface</a></li>
</ul>
<p>You don’t need any prior Django experience to complete this guide. However, to build functionality beyond the basic scaffolding, you’ll need to know <a href="https://realpython.com/products/python-basics-book/">Python basics</a> and at least some <a href="https://realpython.com/learning-paths/django-web-development/">Django</a>.</p>
<h2 id="step-1-prepare-your-environment">Step 1: Prepare Your Environment<a class="headerlink" href="#step-1-prepare-your-environment" title="Permanent link"></a></h2>
<p>When you’re ready to start your new Django web application, create a new folder and navigate into it. In this folder, you’ll set up a new <a href="/ref/glossary/virtual-environment/" class="ref-link">virtual environment</a> using your <a href="/ref/glossary/console/" class="ref-link">terminal</a>:</p>
<ul class="nav nav-tabs justify-content-end js-platform-widget-tabs" role="tablist">
<li class="nav-item mb-0 js-platform-widget-tab-windows" role="presentation">
<a class="nav-link link-unstyled text-body active small" id="windows-tab-1" data-toggle="tab" href="#windows-1" role="tab" aria-controls="windows-1" aria-selected="true"><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#brands--windows"></use></svg></span>Windows</a>
</li>
<li class="nav-item mb-0 js-platform-widget-tab-linuxmacos" role="presentation">
<a class="nav-link link-unstyled text-body small" id="macos-tab-1" data-toggle="tab" href="#linux-macos-1" role="tab" aria-controls="linux-macos-1" aria-selected="false"><span class="icon baseline text-muted" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--linux"></use></svg></span><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--apple"></use></svg></span>Linux + macOS</a>
</li>
</ul>
<div class="tab-content mt-2 mb-0 js-platform-widget-content">
<div aria-labelledby="windows-tab-1" class="tab-pane fade show active" id="windows-1" role="tabpanel">
<code-block class="mb-3" aria-label="Code block" data-syntax-language="pscon" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Windows PowerShell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">PS> </span><span class="n">python</span> <span class="n">-m</span> <span class="n">venv</span> <span class="p">.</span><span class="n">venv</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
</div>
<div aria-labelledby="linux-macos-tab-1" class="tab-pane fade " id="linux-macos-1" role="tabpanel">
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span>python3<span class="w"> </span>-m<span class="w"> </span>venv<span class="w"> </span>.venv
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
</div>
</div>
<p>This command sets up a new virtual environment named <code>.venv</code> in your current working directory. Once the process is complete, you also need to activate the virtual environment:</p>
<ul class="nav nav-tabs justify-content-end js-platform-widget-tabs" role="tablist">
<li class="nav-item mb-0 js-platform-widget-tab-windows" role="presentation">
<a class="nav-link link-unstyled text-body active small" id="windows-tab-2" data-toggle="tab" href="#windows-2" role="tab" aria-controls="windows-2" aria-selected="true"><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#brands--windows"></use></svg></span>Windows</a>
</li>
<li class="nav-item mb-0 js-platform-widget-tab-linuxmacos" role="presentation">
<a class="nav-link link-unstyled text-body small" id="macos-tab-2" data-toggle="tab" href="#linux-macos-2" role="tab" aria-controls="linux-macos-2" aria-selected="false"><span class="icon baseline text-muted" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--linux"></use></svg></span><span class="icon baseline text-muted mr-1" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#v4--apple"></use></svg></span>Linux + macOS</a>
</li>
</ul>
<div class="tab-content mt-2 mb-0 js-platform-widget-content">
<div aria-labelledby="windows-tab-2" class="tab-pane fade show active" id="windows-2" role="tabpanel">
<code-block class="mb-3" aria-label="Code block" data-syntax-language="pscon" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Windows PowerShell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">PS> </span><span class="p">.</span><span class="n">venv</span><span class="p">\</span><span class="n">Scripts</span><span class="p">\</span><span class="n">activate</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
</div>
<div aria-labelledby="linux-macos-tab-2" class="tab-pane fade " id="linux-macos-2" role="tabpanel">
<code-block class="mb-3" aria-label="Code block" data-syntax-language="console" data-is-repl="true">
<div class="codeblock__header codeblock--yellow">
<span class="mr-2 noselect" aria-label="Language">Shell</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">$ </span><span class="nb">source</span><span class="w"> </span>.venv/bin/activate
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
</div>
</div>
<p>If the activation was successful, then you’ll see the name of your virtual environment, <code>(.venv)</code>, at the beginning of your command prompt. This means that your environment setup is complete.</p>
<p>You can learn more about how to <a href="https://realpython.com/python-virtual-environments-a-primer/">work with virtual environments in Python</a>, and how to <a href="https://realpython.com/learning-paths/perfect-your-python-development-setup/">perfect your Python development setup</a>, but for your Django setup, you have all you need. You can continue with installing the <code>django</code> package.</p>
<h2 id="step-2-install-django-and-pin-your-dependencies">Step 2: Install Django and Pin Your Dependencies<a class="headerlink" href="#step-2-install-django-and-pin-your-dependencies" title="Permanent link"></a></h2>
</div><h2><a href="https://realpython.com/django-setup/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/django-setup/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: How to Create a Django Projecthttps://realpython.com/quizzes/django-setup/2026-01-14T12:00:00+00:00Check your Django setup skills. Install safely and pin requirements, create a project and an app. Start building your first site.
<p>In this quiz, you’ll test your understanding of
<a href="https://realpython.com/django-setup/">creating a Django project</a>.</p>
<p>By working through this quiz, you’ll revisit how to create and activate a virtual environment, install Django and pin your dependencies, start a Django project, and start a Django app. You will also see how isolating dependencies helps others reproduce your setup.</p>
<p>To revisit and keep learning, watch the video course on
<a href="https://realpython.com/courses/set-up-django-project/">How to Set Up a Django Project</a>.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Intro to Object-Oriented Programming (OOP) in Pythonhttps://realpython.com/courses/intro-object-oriented-programming/2026-01-13T14:00:00+00:00Learn Python OOP fundamentals fast: master classes, objects, and constructors with hands-on lessons in this beginner-friendly video course.
<p>Object-oriented programming (OOP) is one of the most significant and essential topics in programming. This course will give you a foundational conceptual understanding of object-oriented programming to help you elevate your Python skills.</p>
<p>You’ll learn how to define custom types using classes and how to instantiate those classes into Python objects that can be used throughout your program.</p>
<p>Finally, you’ll discover how classes can inherit from one another, with a brief introduction to inheritance, enabling you to write maintainable and less redundant Python code.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Python's deque: Implement Efficient Queues and Stackshttps://realpython.com/python-deque/2026-01-12T14:00:00+00:00Use a Python deque to efficiently append and pop elements from both ends of a sequence, build queues and stacks, and set maxlen for history buffers.
<div><p>You can use Python’s <code>deque</code> for efficient appends and pops at both ends of a sequence-like data type. These capabilities are critical when you need to implement queue and stack data structures that operate efficiently even under heavy workloads.</p>
<p>In this tutorial, you’ll learn how <code>deque</code> works, when to use it over a <code>list</code>, and how to apply it in real code.</p>
<p><strong>By the end of this tutorial, you’ll understand that:</strong></p>
<ul>
<li><code>deque</code> internally uses a <strong>doubly linked list</strong>, so end operations are <em>O(1)</em> while random indexing is <em>O(n)</em>.</li>
<li>You can build a <strong>FIFO queue</strong> with <strong><code>.append()</code></strong> and <strong><code>.popleft()</code></strong>, and a <strong>LIFO stack</strong> with <strong><code>.append()</code></strong> and <strong><code>.pop()</code></strong>.</li>
<li><code>deque</code> supports <strong>indexing</strong> but doesn’t support <strong>slicing</strong>.</li>
<li>Passing a value to <strong><code>maxlen</code></strong> creates a bounded deque that <strong>drops items</strong> from the opposite end when full.</li>
<li>In CPython, <strong><code>.append()</code></strong>, <strong><code>.appendleft()</code></strong>, <strong><code>.pop()</code></strong>, <strong><code>.popleft()</code></strong>, and <strong><code>len()</code></strong> are <strong>thread-safe</strong> for multithreaded use.</li>
</ul>
<p>Up next, you’ll get started with <code>deque</code>, benchmark it against <code>list</code>, and explore how it shines in real-world use cases, such as queues, stacks, history buffers, and thread-safe producer-consumer setups.</p>
<div class="alert alert-warning" role="alert">
<p><strong markdown>Get Your Code:</strong> <a href="https://realpython.com/bonus/python-deque-code/" class="alert-link" data-toggle="modal" data-target="#modal-python-deque-code" markdown>Click here to download the free sample code</a> that shows you how to implement efficient queues and stacks with Python’s deque.</p>
</div>
<div class="container border rounded text-wrap-pretty my-3">
<p class="my-3"><mark class="marker-highlight"><strong><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span> Take the Quiz:</strong></mark> Test your knowledge with our interactive “Python's deque: Implement Efficient Queues and Stacks” quiz. You’ll receive a score upon completion to help you track your learning progress:</p>
<hr>
<div class="row my-3">
<div class="col-xs-12 col-sm-4 col-md-3 align-self-center">
<a href="/quizzes/python-deque/" tabindex="-1">
<div class="embed-responsive embed-responsive-16by9">
<img class="card-img-top m-0 p-0 embed-responsive-item rounded" style="object-fit: contain; background: #b9abe6;" alt="Python's deque: Implement Efficient Queues and Stacks" src="https://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg" width="1920" height="1080" srcset="/cdn-cgi/image/width=480,format=auto/https://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg 480w, /cdn-cgi/image/width=640,format=auto/https://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg 640w, /cdn-cgi/image/width=960,format=auto/https://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg 960w, /cdn-cgi/image/width=1920,format=auto/https://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg 1920w" sizes="(min-width: 1200px) 142px, (min-width: 1000px) 122px, (min-width: 780px) 112px, (min-width: 580px) 139px, calc(100vw - 62px)">
<div class="card-img-overlay d-flex align-items-center">
<div class="mx-auto">
<span class="text-light" style="opacity: 0.90;"><span class="icon baseline scale2x" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@quiz"></use></svg></span></span>
</div>
</div>
</div>
</a>
</div>
<div class="col">
<div class="mt-3 d-md-none"></div>
<p class="small text-muted mb-0"><strong>Interactive Quiz</strong></p>
<a href="/quizzes/python-deque/" class="stretched-link"><span class="my-0 h4">Python's deque: Implement Efficient Queues and Stacks</span></a>
<p class="text-muted mb-0 small">Use Python's deque for fast queues and stacks. Refresh end operations, maxlen rollover, indexing limits, and thread-safe methods.</p>
</div>
</div>
</div>
<h2 id="get-started-with-pythons-deque">Get Started With Python’s <code>deque</code><a class="headerlink" href="#get-started-with-pythons-deque" title="Permanent link"></a></h2>
<p>Appending to and popping from the right end of a Python <a href="https://realpython.com/python-list/"><code>list</code></a> are efficient operations most of the time. Using the <a href="https://en.wikipedia.org/wiki/Big_O_notation">Big <em>O</em> notation</a> for <a href="https://wiki.python.org/moin/TimeComplexity">time complexity</a>, these operations are <em>O(1)</em>. However, when Python needs to reallocate memory to <em>grow</em> the underlying list to accept new items, these operations slow down and can become <em>O</em>(<em>n</em>).</p>
<p>In contrast, appending and popping items from the left end of a Python list are always inefficient and have <em>O</em>(<em>n</em>) time complexity.</p>
<p>Because Python lists provide both operations with the <a href="https://realpython.com/python-append/"><code>.append()</code></a> and <code>.pop()</code> <a href="/ref/glossary/method/" class="ref-link">methods</a>, you can use them as <a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">stacks</a> and <a href="https://en.wikipedia.org/wiki/Queue_(abstract_data_type)">queues</a>. However, the performance issues you saw before can significantly impact the overall performance of your applications.</p>
<p>Python’s <a href="https://docs.python.org/3/library/collections.html#collections.deque"><code>deque</code></a> was the first data type added to the <a href="https://realpython.com/python-collections-module/"><code>collections</code></a> module back in <a href="https://docs.python.org/3/whatsnew/2.4.html#new-improved-and-deprecated-modules">Python 2.4</a>. This data type was specially designed to overcome the efficiency problems of <code>.append()</code> and <code>.pop()</code> in Python lists.</p>
<p>A deque is a <a href="/ref/glossary/sequence/" class="ref-link">sequence</a>-like <a href="/ref/glossary/data-structure/" class="ref-link">data structure</a> designed as a generalization of <a href="/ref/glossary/stack/" class="ref-link"><strong>stacks</strong></a> and <a href="/ref/glossary/queue/" class="ref-link"><strong>queues</strong></a>. It supports memory-efficient and fast append and pop operations on both ends.</p>
<div class="alert alert-primary" role="alert">
<p><strong>Note:</strong> The word <code>deque</code> is pronounced as “deck.” The name stands for <a href="https://en.wikipedia.org/wiki/Double-ended_queue"><strong>d</strong>ouble-<strong>e</strong>nded <strong>que</strong>ue</a>.</p>
</div>
<p>Append and pop operations on both ends of a <code>deque</code> object are stable and equally efficient because deques are <a href="https://github.com/python/cpython/blob/23acadcc1c75eb74b2459304af70d97a35001b34/Modules/_collectionsmodule.c#L34">implemented</a> as a <a href="https://realpython.com/linked-lists-python/#how-to-use-doubly-linked-lists">doubly linked list</a>. Additionally, append and pop operations on deques are <a href="https://en.wikipedia.org/wiki/Thread_safety">thread-safe</a> and memory-efficient. These features make deques particularly useful for creating custom stacks and queues in Python.</p>
<p>Deques are also a good choice when you need to keep a list of recently seen items, as you can restrict the maximum length of your deque. By setting a maximum length, once a deque is full, it automatically discards items from one end when you append new items to the opposite end.</p>
<p>Here’s a summary of the main features of <code>deque</code>:</p>
<ul>
<li>Stores items of any <a href="https://realpython.com/python-data-types/">data type</a></li>
<li>Is a <a href="/ref/glossary/mutable/" class="ref-link">mutable</a> data type</li>
<li>Supports <a href="https://realpython.com/python-in-operator/">membership operations</a> with the <a href="/ref/keywords/in/" class="ref-link"><code>in</code> operator</a></li>
<li>Supports <a href="/ref/glossary/indexing/" class="ref-link">indexing</a>, like in <code>a_deque[i]</code></li>
<li>Doesn’t support <a href="/ref/glossary/slicing/" class="ref-link">slicing</a>, like in <code>a_deque[0:2]</code></li>
<li>Supports <a href="https://realpython.com/python-built-in-functions/">built-in functions</a> that operate on <a href="https://realpython.com/python-sequences/">sequences</a> and <a href="https://realpython.com/python-iterators-iterables/">iterables</a>, such as <a href="https://realpython.com/len-python-function/"><code>len()</code></a>, <a href="https://realpython.com/python-sort/"><code>sorted()</code></a>, <a href="https://realpython.com/python-reverse-list/"><code>reversed()</code></a>, and more</li>
<li>Doesn’t support <a href="https://en.wikipedia.org/wiki/In-place_algorithm">in-place</a> sorting</li>
<li>Supports normal and reverse <a href="/ref/glossary/iteration/" class="ref-link">iteration</a></li>
<li>Supports pickling with <a href="https://realpython.com/python-pickle-module/"><code>pickle</code></a></li>
<li>Supports fast, memory-efficient, and <a href="https://realpython.com/python-thread-lock/">thread-safe</a> pop and append operations on both ends</li>
</ul>
<p>To create deques, you just need to import <code>deque</code> from <code>collections</code> and call it with an optional <a href="/ref/glossary/iterable/" class="ref-link">iterable</a> as an <a href="/ref/glossary/argument/" class="ref-link">argument</a>:</p>
<code-block class="mb-3" aria-label="Code block" data-syntax-language="pycon" data-is-repl="true">
<div class="codeblock__header codeblock--blue">
<span class="mr-2 noselect" aria-label="Language">Python</span>
<div class="noselect">
<span class="codeblock__output-toggle" title="Toggle prompts and output" role="button"><span class="icon baseline js-codeblock-output-on codeblock__header--icon-lower" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#regular--rectangle-terminal"></use></svg></span></span>
</div>
</div>
<div class="codeblock__contents">
<div class="highlight highlight--with-header"><pre><span></span><code><span class="gp">>>> </span><span class="kn">from</span><span class="w"> </span><span class="nn">collections</span><span class="w"> </span><span class="kn">import</span> <span class="n">deque</span>
<span class="gp">>>> </span><span class="c1"># Create an empty deque</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">()</span>
<span class="go">deque([])</span>
<span class="gp">>>> </span><span class="c1"># Use different iterables to create deques</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">deque([1, 2, 3, 4])</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
<span class="go">deque([1, 2, 3, 4])</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">deque([1, 2, 3, 4])</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">(</span><span class="s2">"abcd"</span><span class="p">)</span>
<span class="go">deque(['a', 'b', 'c', 'd'])</span>
<span class="gp">>>> </span><span class="n">numbers</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"one"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"two"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s2">"three"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="s2">"four"</span><span class="p">:</span> <span class="mi">4</span><span class="p">}</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">(</span><span class="n">numbers</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
<span class="go">deque(['one', 'two', 'three', 'four'])</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">(</span><span class="n">numbers</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="go">deque([1, 2, 3, 4])</span>
<span class="gp">>>> </span><span class="n">deque</span><span class="p">(</span><span class="n">numbers</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
<span class="go">deque([('one', 1), ('two', 2), ('three', 3), ('four', 4)])</span>
</code></pre></div>
<button class="codeblock__copy btn btn-outline-secondary border m-1 px-1 d-hover-only" title="Copy to clipboard"><span class="icon baseline" aria-hidden="true"><svg aria-hidden="true"><use href="/static/icons.e98ec7a26cad.svg#@copy"></use></svg></span></button>
</div>
</code-block>
<p>If you instantiate <code>deque</code> without providing an <code>iterable</code> as an argument, then you get an empty deque. If you provide an <code>iterable</code>, then <code>deque</code> initializes the new instance with data from it. The initialization goes from left to right using <code>deque.append()</code>.</p>
<p>The <code>deque</code> initializer takes the following two <a href="https://realpython.com/python-optional-arguments/">optional arguments</a>:</p>
<ol>
<li><strong><code>iterable</code></strong> holds an iterable that provides the initialization data.</li>
<li><strong><code>maxlen</code></strong> holds an integer <a href="https://realpython.com/python-numbers/">number</a> that specifies the maximum length of the deque.</li>
</ol>
<p>As mentioned previously, if you don’t supply an <code>iterable</code>, then you get an empty deque. If you provide a value to <a href="https://docs.python.org/3/library/collections.html#collections.deque.maxlen"><code>maxlen</code></a>, then your deque will only store up to <code>maxlen</code> items.</p>
<p>Finally, you can also use unordered iterables, such as <a href="https://realpython.com/python-sets/">sets</a>, to initialize your deques. In those cases, you won’t have a predefined order for the items in the final deque.</p>
</div><h2><a href="https://realpython.com/python-deque/?utm_source=realpython&utm_medium=rss">Read the full article at https://realpython.com/python-deque/ »</a></h2>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #279: Coding Python With Confidence: Beginners Live Course Participantshttps://realpython.com/podcasts/rpp/279/2026-01-09T12:00:00+00:00Are you looking for that solid foundation to begin your Python journey? Would the accountability of scheduled group classes help you get through the basics and start building something? This week, two members of the Python for Beginners live course discuss their experiences.
<p>Are you looking for that solid foundation to begin your Python journey? Would the accountability of scheduled group classes help you get through the basics and start building something? This week, two members of the Python for Beginners live course discuss their experiences.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Tips for Using the AI Coding Editor Cursorhttps://realpython.com/courses/tips-using-ai-coding-editor-cursor/2026-01-06T14:00:00+00:00Learn Cursor fast: Use AI-powered coding with agents, project-aware chat, and inline edits to supercharge your VS Code workflow.
<p>Cursor is an AI-powered integrated development environment (IDE) based on the Visual Studio Code codebase. It comes with a multi-agent interface and the Composer model for fast, agentic coding while keeping a familiar editor workflow with project-aware chat, code completion, and inline edits.</p>
<p>In this course, you will: </p>
<ul>
<li>Understand why Cursor might work for you</li>
<li>Learn how to use different modes & models</li>
<li>See how to run multiple agents at a time</li>
<li>Resolve a tiny merge conflict</li>
<li>Run a project and fix a bug</li>
<li>Learn commands and practice with the terminal</li>
</ul>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: How to Properly Indent Python Codehttps://realpython.com/quizzes/how-to-indent-in-python/2026-01-05T12:00:00+00:00Practice proper Python indentation. Take a quiz on using spaces, editor settings, and autoformatting correctly.
<p>In this quiz, you’ll test your understanding of
<a href="https://realpython.com/how-to-indent-in-python/">How to Indent in Python</a>.</p>
<p>By working through this quiz, you’ll revisit how to properly indent Python code, choose helpful editor settings, use spaces properly, apply code formatters, and explain why indentation is required.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: How to Convert Bytes to Strings in Pythonhttps://realpython.com/quizzes/convert-python-bytes-to-strings/2026-01-05T12:00:00+00:00Decode bytes into readable strings in Python. Test your skills working with data from files, APIs, and databases.
<p>In this quiz, you’ll test your understanding of the
<a href="https://realpython.com/convert-python-bytes-to-strings/">Convert Python Bytes to Strings</a> tutorial.</p>
<p>By working through this quiz, you’ll revisit how to decode bytes, choose an encoding, and turn binary data into readable text.</p>
<p>You’ll also see how encodings map byte values to characters so you can handle data from files, databases, and APIs with confidence. For a deeper dive, check out <a href="https://realpython.com/python-encodings-guide/">Python Encodings: A Guide</a> and <a href="https://realpython.com/python-bytes/">Python Bytes</a>.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #278: PyCoder's Weekly 2025 Top Articles & Hidden Gemshttps://realpython.com/podcasts/rpp/278/2026-01-02T12:00:00+00:00PyCoder's Weekly included over 1,500 links to articles, blog posts, tutorials, and projects in 2025. Christopher Trudeau is back on the show this week to help wrap up everything by sharing some highlights and uncovering a few hidden gems from the pile.
<p>PyCoder's Weekly included over 1,500 links to articles, blog posts, tutorials, and projects in 2025. Christopher Trudeau is back on the show this week to help wrap up everything by sharing some highlights and uncovering a few hidden gems from the pile.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Quiz: LlamaIndex in Python: A RAG Guide With Exampleshttps://realpython.com/quizzes/llamaindex-examples/2025-12-24T12:00:00+00:00Take this Python LlamaIndex quiz to test your understanding of index persistence, reloading, and performance gains in RAG applications.
<p>In this quiz, you’ll test your understanding of the <a href="https://realpython.com/llamaindex-examples/">LlamaIndex in Python: A RAG Guide With Examples</a> tutorial.</p>
<p>By working through this quiz, you’ll revisit how to create and persist an index to disk, review how to reload it, and see why persistence improves performance, lowers costs, saves time, and keeps results consistent.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Reading User Input From the Keyboard With Pythonhttps://realpython.com/courses/reading-user-input-from-keyboard/2025-12-23T14:00:00+00:00Master taking user input in Python to build interactive terminal apps with clear prompts, solid error handling, and smooth multi-step flows.
<p>You may often want to make your Python programs more interactive by responding dynamically to input from the user. Learning how to read user input from the keyboard unlocks exciting possibilities and can make your code far more useful.</p>
<p>The ability to gather input from the keyboard with Python allows you to build programs that can respond uniquely based on the preferences, decisions, or data provided by different users. By fetching input and assigning it to variables, your code can react to adjustable conditions rather than just executing static logic flows. This personalizes programs to individual users.</p>
<p>The <code>input()</code> function is the simplest way to get keyboard data from the user in Python. When called, it asks the user for input with a prompt that you specify, and it waits for the user to type a response and press the <span class="keys"><kbd class="key-enter">Enter</kbd></span> key before continuing. This response string is returned by <code>input()</code> so you can save it to a variable or use it directly.</p>
<p>Using only Python, you can start building interactive programs that accept customizable data from the user right within the terminal. Taking user input is an essential skill that unlocks more dynamic Python coding and allows you to elevate simple scripts into personalized applications.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #277: Moving Towards Spec-Driven Developmenthttps://realpython.com/podcasts/rpp/277/2025-12-19T12:00:00+00:00What are the advantages of spec-driven development compared to vibe coding with an LLM? Are these recent trends a move toward declarative programming? This week on the show, Marc Brooker, VP and Distinguished Engineer at AWS, joins us to discuss specification-driven development and Kiro.
<p>What are the advantages of spec-driven development compared to vibe coding with an LLM? Are these recent trends a move toward declarative programming? This week on the show, Marc Brooker, VP and Distinguished Engineer at AWS, joins us to discuss specification-driven development and Kiro.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Exploring Asynchronous Iterators and Iterableshttps://realpython.com/courses/asynchronous-iterators-iterables/2025-12-16T14:00:00+00:00Learn to build async iterators and iterables in Python to handle async operations efficiently and write cleaner, faster code.
<p>When you write asynchronous code in Python, you’ll likely need to create asynchronous iterators and iterables at some point. Asynchronous iterators are what Python uses to control <code>async for</code> loops, while asynchronous iterables are objects that you can iterate over using <code>async for</code> loops.</p>
<p>Both tools allow you to iterate over awaitable objects without blocking your code. This way, you can perform different tasks asynchronously.</p>
<p><strong>In this video course, you’ll:</strong></p>
<ul>
<li>Learn what <strong>async iterators</strong> and <strong>iterables</strong> are in Python</li>
<li>Create async <strong>generator expressions</strong> and <strong>generator iterators</strong></li>
<li>Code async iterators and iterables with the <strong><code>.__aiter__()</code></strong> and <strong><code>.__anext__()</code></strong> methods</li>
<li>Use async iterators in <strong>async loops</strong> and <strong>comprehensions</strong></li>
</ul>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Using Functional Programming in Pythonhttps://realpython.com/courses/using-functional-programming/2025-12-09T14:00:00+00:00Boost your Python skills with a quick dive into functional programming: what it is, how Python supports it, and why it matters.
<p><strong>Functional programming</strong> is a programming paradigm in which the primary method of computation is the evaluation of functions. But how does Python support functional programming?</p>
<p><strong>In this video course, you’ll learn:</strong></p>
<ul>
<li>What the <strong>functional programming</strong> paradigm entails</li>
<li>What it means to say that <strong>functions</strong> are <strong>first-class citizens</strong> in Python</li>
<li>How to define <strong>anonymous functions</strong> with the <strong><code>lambda</code></strong> keyword</li>
<li>How to implement functional code using <strong><code>map()</code></strong>, <strong><code>filter()</code></strong>, and <strong><code>reduce()</code></strong></li>
</ul>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #276: Exploring Quantum Computing & Python Frameworkshttps://realpython.com/podcasts/rpp/276/2025-12-05T12:00:00+00:00What are the recent advances in the field of quantum computing and high-performance computing? And what Python tools can you use to develop programs that run on quantum computers? This week on the show, Real Python author Negar Vahid discusses her tutorial, "Quantum Computing Basics With Qiskit."
<p>What are the recent advances in the field of quantum computing and high-performance computing? And what Python tools can you use to develop programs that run on quantum computers? This week on the show, Real Python author Negar Vahid discusses her tutorial, "Quantum Computing Basics With Qiskit."</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
Introduction to pandashttps://realpython.com/courses/introduction-pandas/2025-12-02T14:00:00+00:00Learn pandas DataFrames: explore, clean, and visualize data with powerful tools for analysis. Delete unneeded data, import data from a CSV file, and more.
<p>The <a href="https://pandas.pydata.org/pandas-docs/stable/reference/frame.html">pandas DataFrame</a> is a <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/dsintro.html">structure</a> that contains <strong>two-dimensional data</strong> and its corresponding <strong>labels</strong>. DataFrames are widely used in <a href="https://realpython.com/tutorials/data-science/">data science</a>, <a href="https://realpython.com/tutorials/machine-learning/">machine learning</a>, scientific computing, and many other data-intensive fields.</p>
<p>DataFrames are similar to <a href="https://realpython.com/python-sql-libraries/">SQL tables</a> or the spreadsheets that you work with in Excel or Calc. In many cases, DataFrames are faster, easier to use, and more powerful than tables or spreadsheets because they’re an integral part of the <a href="https://www.python.org/about/">Python</a> and <a href="https://numpy.org/">NumPy</a> ecosystems.</p>
<p><strong>In this video course, you’ll learn:</strong></p>
<ul>
<li>What a <strong>pandas DataFrame</strong> is and how to create one</li>
<li>How to <strong>access, modify, add, sort, filter, and delete</strong> data</li>
<li>How to handle <strong>missing values</strong></li>
<li>How to work with <strong>time-series data</strong></li>
<li>How to quickly <strong>visualize</strong> data</li>
</ul>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>
The Real Python Podcast – Episode #275: Building a FastAPI Application & Exploring Python Concurrencyhttps://realpython.com/podcasts/rpp/275/2025-11-21T12:00:00+00:00What are the steps to get started building a FastAPI application? What are the different types of concurrency available in Python? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder's Weekly articles and projects.
<p>What are the steps to get started building a FastAPI application? What are the different types of concurrency available in Python? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder's Weekly articles and projects.</p>
<hr />
<p><em>[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. <a href="https://realpython.com/python-tricks/?utm_source=realpython&utm_medium=rss&utm_campaign=footer">>> Click here to learn more and see examples</a> ]</em></p>