PLAY PODCASTS
Defining Optional Arguments and Moving Beyond "Beginner" Python
Episode 100

Defining Optional Arguments and Moving Beyond "Beginner" Python

The Real Python Podcast · Real Python

March 4, 202253m 24s

Audio is streamed directly from the publisher (dts.podtrac.com) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

<p>How do you define Python functions that accept optional arguments or default values? Are you wondering how to go beyond being a beginner with Python? This week on the show, Christopher Trudeau is here, and he&rsquo;s brought another batch of PyCoder&rsquo;s Weekly articles and projects.</p> <p>Christopher shares a Real Python article, &ldquo;Defining Python Functions With Optional Arguments.&rdquo; We talk about function flexibility, specifying default values, and using <code>args</code> &amp; <code>kwargs</code>. </p> <p>We discuss resources for a Python beginner to move beyond the basics and become more competent. Both of us share our experiences moving past these hurdles.</p> <p>We cover several other articles and projects from the Python community, including a news roundup, ten tools you may have wished you knew when you started working with Python, Python&rsquo;s <code>zipfile</code> for manipulating your zip files efficiently, how one company optimized Python API server code by 100x, a dependency-free Python library for downloading YouTube videos, and how to use Python on the command line with other shell commands. </p> <div class="alert alert-primary" role="alert"> <p><strong>Course Spotlight:</strong> <a href="https://realpython.com/courses/defining-python-functions-with-optional-arguments/">Defining Python Functions With Optional Arguments</a></p> <p>In this video course, you&rsquo;ll learn about Python optional arguments and how to define functions with default values. You&rsquo;ll also learn how to create functions that accept any number of arguments using args and kwargs.</p> </div> <p>Topics:</p> <ul> <li>00:00:00 &ndash; Introduction</li> <li>00:03:08 &ndash; Django Project Reformats Entire Codebase With Black</li> <li>00:03:53 &ndash; PEP 673: Self Type Was Accepted</li> <li>00:05:16 &ndash; PEP 654 Accepted: Exception Groups</li> <li>00:07:45 &ndash; Upcoming Python Feature PEPs</li> <li>00:10:01 &ndash; Defining Python Functions With Optional Arguments</li> <li>00:15:12 &ndash; Sponsor: CData Software</li> <li>00:15:53 &ndash; 10 Tools I Wish I Knew When I Started Working With Python</li> <li>00:23:22 &ndash; How We Optimized Python API Server Code 100x</li> <li>00:29:47 &ndash; Python&rsquo;s zipfile: Manipulate Your ZIP Files Efficiently</li> <li>00:32:47 &ndash; Video Course Spotlight</li> <li>00:33:59 &ndash; How Do I Go From Being a Beginner to Competent in Python?</li> <li>00:47:02 &ndash; pytube: Dependency-Free Python Library for Downloading &ndash; YouTube Videos</li> <li>00:49:30 &ndash; pz: Use Python on the Command Line With Other Shell Commands</li> <li>00:52:23 &ndash; Thanks and goodbye</li> </ul> <p>News:</p> <ul> <li><a href="https://github.com/django/django/pull/15387">Django Project Reformats Entire Codebase With Black</a> &ndash; Related discussion on <a href="https://news.ycombinator.com/item?id=30258530">Hacker News</a>.</li> <li><a href="https://www.python.org/dev/peps/pep-0673/">PEP 673: Self Type Was Accepted</a> &ndash; This PEP introduces a simple and intuitive way to annotate methods that return an instance of their class. This behaves the same as the <code>TypeVar</code>-based approach specified in PEP 484 but is more concise and easier to follow. <a href="https://twitter.com/raymondh/status/1491187805636407298">Related Twitter thread by core dev Raymond Hettinger.</a></li> <li><a href="https://www.python.org/dev/peps/pep-0654/">PEP 654 Accepted: Exception Groups</a> &ndash; New standard for grouping exceptions together</li> <li><a href="https://martinheinz.dev/blog/67">Upcoming Python Feature PEPs</a> &ndash; &ldquo;These PEPs are a great way of getting the freshest info about what might be included in the upcoming Python releases. So, in this article we will go over all the proposals that are going to bring some exciting new Python features in a near future!&rdquo;</li> </ul> <p>Topics:</p> <ul> <li><a href="https://realpython.com/courses/defining-python-functions-with-optional-arguments/">Defining Python Functions With Optional Arguments</a> &ndash; Learn about Python optional arguments and how to define functions with default values. You&rsquo;ll also see how to create functions that accept any number of arguments using <code>*args</code> and <code>**kwargs</code>.</li> <li><a href="https://python.plainenglish.io/10-tools-to-help-claw-your-way-back-to-sanity-while-coding-python-df0af160c33e">10 Tools I Wish I Knew When I Started Working With Python</a> &ndash; Learn about how venvs, flake8, black, isort, pytest, commitizen, semantic-release, pre-commit hooks, and Github Actions work together! </li> <li><a href="https://towardsdatascience.com/how-we-optimized-python-api-server-code-100x-9da94aa883c5">How We Optimized Python API Server Code 100x</a> &ndash; Tricks we used to speed up calls to our analytical API written in Python: asyncio, SQLAlchemy, asyncpg, Cython plugins, improved data structures, and replaced some Pandas with NumPy.</li> <li><a href="https://realpython.com/python-zipfile/">Python&rsquo;s zipfile: Manipulate Your ZIP Files Efficiently</a> &ndash; In this guided tutorial, you&rsquo;ll learn how to manipulate ZIP files using Python&rsquo;s zipfile module from the standard library. Through hands-on examples, you&rsquo;ll learn how to read, write, compress, and extract files from your ZIP files quickly.</li> <li><a href="https://news.ycombinator.com/item?id=30357094">How Do I Go From Being a Beginner to Competent in Python?</a></li> </ul> <p>Projects:</p> <ul> <li><a href="https://github.com/pytube/">pytube: Dependency-Free Python Library for Downloading YouTube Videos</a></li> <li><a href="https://github.com/CZ-NIC/pz">pz: Use Python on the Command Line With Other Shell Commands</a></li> </ul> <p>Additional Links:</p> <ul> <li><a href="https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/">Fluent Python, 2nd Edition</a></li> <li><a href="http://www.dabeaz.com/python-distilled/">Python Distilled</a></li> <li><a href="https://learnbyexample.github.io/py_resources/intermediate.html">Intermediate to Advanced resources - Python resources for everybody</a></li> <li><a href="https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world">The Flask Mega-Tutorial Part I: Hello, World!</a></li> </ul> <p>Level up your Python skills with our expert-led courses:</p> <ul> <li><a href="https://realpython.com/courses/defining-python-functions-with-optional-arguments/">Defining Python Functions With Optional Arguments</a></li> <li><a href="https://realpython.com/courses/defining-and-calling-functions/">Defining and Calling Python Functions</a></li> <li><a href="https://realpython.com/courses/writing-beautiful-python-code-pep-8/">Writing Beautiful Pythonic Code With PEP 8</a></li> </ul> <p><a rel="payment" href="https://realpython.com/join">Support the podcast &amp; join our community of Pythonistas</a></p>