PLAY PODCASTS
Package Python Code With pyproject.toml & Listing Files With pathlib
Episode 136

Package Python Code With pyproject.toml & Listing Files With pathlib

The Real Python Podcast · Real Python

December 9, 202254m 8s

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 start packaging your code with pyproject.toml? Would you like to join a conversation that gently walks you through setting up your Python projects to share? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder&rsquo;s Weekly articles and projects.</p> <p>We discuss a recent code conversation featuring Real Python team members Ian Currie and Geir Arne Hjelle. The video dives into the officially sanctioned way to configure your project using a <code>pyproject.toml</code> file. We cover how this relatively new approach will help you package your code for use on your system or for sharing with others.</p> <p>Christopher shares a Real Python tutorial about using <code>pathlib</code> to get a list of all the files within a directory. We&rsquo;re both fans of <code>pathlib</code> and how it simplifies working with file paths. The tutorial digs into methods to recursively list all directory contents or create a conditional listing. </p> <p>We share several other articles and projects from the Python community, including an explanation of Python bytecode, an argument for always using <code>[closed, open)</code> intervals, a discussion about building the monolith before microservices, a way to parse natural language time and date expressions, and a project for posting on Mastodon.</p> <div class="alert alert-primary" role="alert"> <p><strong>Course Spotlight:</strong> <a href="https://realpython.com/courses/pathlib-python/">Using Python&rsquo;s pathlib Module</a></p> <p>In this video course, you&rsquo;ll learn how to effectively work with file system paths in Python 3 using the <code>pathlib</code> module in the standard library.</p> </div> <p>Topics:</p> <ul> <li>00:00:00 &ndash; Introduction</li> <li>00:02:30 &ndash; Always Use <code>[closed, open)</code> Intervals</li> <li>00:07:05 &ndash; Everyday Project Packaging With <code>pyproject.toml</code></li> <li>00:15:38 &ndash; Sponsor: InfluxDB</li> <li>00:16:27 &ndash; How to Get a List of All Files in a Directory With Python</li> <li>00:20:37 &ndash; Python Bytecode Explained</li> <li>00:29:39 &ndash; Video Course Spotlight</li> <li>00:30:48 &ndash; Build the Modular Monolith First</li> <li>00:44:34 &ndash; toot - PyPI</li> <li>00:49:58 &ndash; quickadd: Parse Natural Language Time and Date Expressions</li> <li>00:53:09 &ndash; Thanks and goodbye</li> </ul> <p>Show Links:</p> <ul> <li><a href="https://fhur.me/posts/always-use-closed-open-intervals">Always Use <code>[closed, open)</code> Intervals</a> &ndash; &ldquo;Intervals or ranges pop-up everywhere in the programming world. The classic example is picking a start and end date, like you would when booking an AirBnB or a flight. Have you ever wondered why they are always implemented as [closed, open) as opposed to [closed, closed]?&rdquo;</li> <li><a href="https://realpython.com/courses/packaging-with-pyproject-toml/">Everyday Project Packaging With <code>pyproject.toml</code></a> &ndash; In this Code Conversation video course, you&rsquo;ll learn how to package your everyday projects with <code>pyproject.toml</code>. Playing on the same team as the import system means you can call your project from anywhere, ensure consistent imports, and have one file that&rsquo;ll work for many build systems.</li> <li><a href="https://realpython.com/get-all-files-in-directory-python/">How to Get a List of All Files in a Directory With Python</a> &ndash; In this tutorial, you&rsquo;ll be examining a couple of methods to get a list of files and folders in a directory with Python. You&rsquo;ll also use both methods to recursively list directory contents. Finally, you&rsquo;ll examine a situation that pits one method against the other.</li> <li><a href="https://github.com/MoserMichael/pyasmtool/blob/master/bytecode_disasm.md">Python Bytecode Explained</a> &ndash; When a Python program is run, the interpreter first parses your code and checks for syntax errors, then it translates it into bytecode instructions. This article explains some of the features of Python bytecode.</li> </ul> <p>Discussion:</p> <ul> <li><a href="https://www.fearofoblivion.com/build-a-modular-monolith-first">Build the Modular Monolith First</a> &ndash; &ldquo;Even talking about building a monolith today, is a bit taboo. It is all about microservices at the moment, and has been for a few years. But they aren&rsquo;t a silver bullet.&rdquo; Coding samples in the article aren&rsquo;t Python, but the architectural advice is cross-language.</li> <li><a href="https://www.martinfowler.com/articles/distributed-objects-microservices.html">Microservices and the First Law of Distributed Objects</a></li> <li><a href="https://twitter.com/jasoncwarner/status/1592227285024636928">&ldquo;I&rsquo;m convinced that one of the biggest architectural mistakes of the past decade was going full microservice&rdquo; Jason Warner - Twitter</a></li> </ul> <p>Projects:</p> <ul> <li><a href="https://pypi.org/project/toot/">toot - PyPI</a></li> <li><a href="https://github.com/Acreom/quickadd">quickadd: Parse Natural Language Time and Date Expressions</a></li> </ul> <p>Additional Links:</p> <ul> <li><a href="https://www.youtube.com/watch?v=v6tALyc4C10">Packaging Your Python Code With pyproject.toml | Complete Code Conversation - YouTube</a></li> <li><a href="https://realpython.com/pypi-publish-python-package/">How to Publish an Open-Source Python Package to PyPI – Real Python</a></li> <li><a href="https://pypackages.com/">Publishing Python Packages: Test, share, and automate your projects | Dane Hillard</a></li> <li><a href="https://realpython.com/podcasts/rpp/83/">Episode #83: Ready to Publish Your Python Packages? – The Real Python Podcast</a></li> <li><a href="https://github.com/MoserMichael/python-obj-system/blob/master/README.md">Advanced Course on Python3 - MoserMichael - GitHub</a></li> <li><a href="https://github.com/MoserMichael/pyasmtool">pyasmtool: Explores the Python bytecode, provides some tools to access it for fun and profit. - GitHub</a></li> <li><a href="https://realpython.com/podcasts/rpp/39/">Episode #39: Generators, Coroutines, and Learning Python Through Exercises – The Real Python Podcast</a></li> <li><a href="https://realpython.com/podcasts/rpp/47/">Episode #47: Unraveling Python&rsquo;s Syntax to Its Core With Brett Cannon – The Real Python Podcast</a></li> <li><a href="https://snarky.ca/mvpy-minimum-viable-python/">MVPy: Minimum Viable Python</a></li> <li><a href="https://realpython.com/podcasts/rpp/124/">Episode #124: Exploring Recursion in Python With Al Sweigart – The Real Python Podcast</a></li> <li><a href="https://www.martinfowler.com/articles/distributed-objects-microservices.html">Microservices and the First Law of Distributed Objects</a></li> <li><a href="https://talkpython.fm/episodes/show/390/mastodon-for-python-devs">Mastodon for Python Devs - Talk Python #390</a></li> <li><a href="https://simonwillison.net/2022/Nov/8/mastodon-is-just-blogs/">Mastodon is just blogs</a> </li> <li><a href="https://www.w3.org/TR/activitypub/">ActivityPub</a></li> <li><a href="https://awesomeopensource.com/projects/activitypub">The Top 239 Activitypub Open Source Projects</a></li> <li><a href="https://dev.to/andypiper/a-opportunity-for-developers-1ee4">A 🦣 opportunity for developers - DEV Community 👩‍💻👨‍💻</a></li> <li><a href="https://medium.com/@martin.heinz/getting-started-with-mastodon-api-in-python-9f105309ed43">Getting Started with Mastodon API in Python | Martin Heinz - Medium</a></li> <li><a href="https://twitter.com/cltrudeau">Christopher Trudeau (@cltrudeau) - Twitter</a></li> <li><a href="https://twitter.com/digiglean">Christopher Bailey | (@digiglean) - Twitter</a></li> <li><a href="https://fosstodon.org/@digiglean">Christopher Bailey (@[email protected]) - Fosstodon</a></li> <li><a href="https://fosstodon.org/@realpython">Real Python (@[email protected]) - Fosstodon</a></li> </ul> <p>Level up your Python skills with our expert-led courses:</p> <ul> <li><a href="https://realpython.com/courses/lists-tuples-python/">Lists and Tuples in Python</a></li> <li><a href="https://realpython.com/courses/packaging-with-pyproject-toml/">Everyday Project Packaging With pyproject.toml</a></li> <li><a href="https://realpython.com/courses/pathlib-python/">Using Python&#x27;s pathlib Module</a></li> </ul> <p><a rel="payment" href="https://realpython.com/join">Support the podcast &amp; join our community of Pythonistas</a></p>