New PEPs: Template Strings & External Wheel Hosting
Nov 8, 2024
auto_awesome
Christopher Trudeau, a regular contributor from PyCoder's Weekly, dives into recent Python Enhancement Proposals, including PEP 750, which introduces safer string formatting, and PEP 759 for external resource hosting. The discussion covers the exciting updates in Python 3.13, innovative solutions for solving Sudoku puzzles, and the introduction of a debugging tool for HTTP requests. Trudeau also shares insights on mentoring within the tech community, highlighting modern tools like Scrapling for guiding newcomers.
The introduction of template strings through PEP 750 offers deferred evaluation benefits for logging and security in Python development.
PEP 759 addresses hosting concerns by allowing safe project resource linking to external sites via a new .rim file format.
Deep dives
New Python Enhancement Proposals
A discussion of new Python enhancement proposals (PEPs) highlights the introduction of template strings through PEP 750 and the safe hosting of project resources via PEP 759. Template strings, or 'T-strings' as proposed, offer deferred evaluation similar to F-strings, making them beneficial for scenarios like logging, translation, and avoiding injection attacks. PEP 759 aims to address bandwidth concerns by allowing projects that host large libraries to use a new file format called .rim, which links to external resources without overloading the Python Package Index (PyPI). These proposals are still under discussion but represent significant evolutions in Python's capabilities.
Python 3.13 Features and Improvements
The latest features and improvements in Python 3.13, including updates to the Python Debugger (PDB) and file system operation enhancements, are highlighted as compelling reasons to upgrade. Enhancements such as multi-line editing and code completion in PDB can improve user experience significantly, while the inclusion of recursive operations in the shutil library streamlines file handling. Moreover, improvements in concurrency methods and an increase in the multiprocessing pool limit enhance the efficiency of Python's asynchronous capabilities. Despite some performance concerns, these incremental updates provide valuable utility and pave the way for future enhancements.
Syntactic Sugar in Python
An exploration of Python's syntactic sugar discusses its role in making the language more user-friendly and readable. The article delves into various constructs, such as decorators and F-strings, which provide concise and elegant ways to write code by abstracting complex behaviors. Understanding these constructs requires familiarity with underlying mechanisms, including special methods that enable operator overloading and context management. By examining syntactic sugar, developers can grasp Python's design philosophy and improve their coding practices, especially when transitioning from other programming languages.
Mentorship in Programming
The importance of mentorship in programming is examined, emphasizing the mutual benefits for both mentors and mentees. Clear goal-setting and consistent communication are crucial to successful mentoring relationships, aiding both parties in navigating learning paths effectively. Mentors should focus on guiding mentees while recognizing that each individual’s journey is unique, fostering an environment of collaboration rather than dictation. This approach not only enhances technical skills but also contributes to personal growth and confidence in navigating programming challenges, creating a supportive community within the tech industry.
Have you wanted the flexibility of f-strings but need safety checks in place? What if you could have deferred evaluation for logging or avoiding injection attacks? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder’s Weekly articles and projects.
We discuss a set of recent Python Enhancement Proposals (PEPs). The idea of template strings has been under consideration for a while, and PEP 750 describes a new way forward. PEP 759 proposes a way for projects on PyPI to safely host resources on external sites using a new package upload format called a .rim file.
We share several other articles and projects from the Python community, including what didn’t make the headlines about Python 3.13, solving Sudoku with Python packaging, what’s sweet about Python’s syntactic sugar, creating database-generated columns using SQLite and Django, a discussion about mentoring, an adaptive web scraper, and a debugging tool for HTTP(S) client requests.
Discover the power of Pydantic, Python’s most popular data parsing, validation, and serialization library. In this hands-on video course, you’ll learn how to make your code more robust, trustworthy, and easier to debug with Pydantic.
Topics:
00:00:00 – Introduction
00:02:08 – Python 3.14.0 Alpha 1 Released
00:02:38 – Python 3.13, What Didn’t Make the Headlines
00:05:23 – What’s up Python? 3.13 is out, t-strings look awesome
00:10:21 – Sponsor: Sentry
00:11:25 – Sudoku in Python Packaging
00:14:29 – Syntactic Sugar: Why Python Is Sweet and Pythonic
Python 3.13, What Didn’t Make the Headlines – Bite Code summarizes some of the lesser covered changes to Python in the 3.13 release, including how some of the REPL improvements made it into pdb, improvements to shutil, and small additions to the asyncio library.
Sudoku in Python Packaging – Simon writes about a Sudoku solver written by Konstin that uses the Python packaging mechanisms to do Sudoku puzzles. The results are output using a requirements.txt file, where sudoku-0-3==5 represents the (0,3) cell’s answer of 5.
Syntactic Sugar: Why Python Is Sweet and Pythonic – In this tutorial, you’ll learn what syntactic sugar is and how Python uses it to help you create more readable, descriptive, clean, and Pythonic code. You’ll also learn how to replace a given piece of syntactic sugar with another syntax construct.
Mentors – Ryan just finished his second round of mentoring with the Djangonaut.Space program. This post talks about how you can help your mentor help you and how to be a good mentor.