What are real-life examples of using Python decorators? How can you harness their power in your code? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder’s Weekly articles and projects.
We discuss a recent article series that digs into Python decorators. The first two articles discuss the basics of constructing decorators. The third part describes how popular Python libraries use decorators with call interception, function registration, and enriching the behavior of a function.
Christopher shares a piece about the common pitfalls of working with the Pythondatetime
library. The article considers how current third-party libraries don’t address most of these quirks and offers a potential solution with a new library.
We also share several other articles and projects from the Python community, including a couple of news items, a discussion about the popularity of the Rust language, handling unset values in FastAPI with Pydantic, working with Python’s mini-language for formatting strings, mocking Django queryset functions, and a modern replacement for the Requests library.
This week’s episode is brought to you by Sentry.
Course Spotlight: Python Decorators 101
In this course on Python decorators, you’ll learn what they are and how to create and use them. Decorators provide a simple syntax for calling higher-order functions in Python. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.
Topics:
datetime
PitfallsNews:
Show Links:
datetime
Pitfalls – It’s no secret that the Python datetime
library has its quirks. Not only are there probably more than you think, but third-party libraries don’t address most of them! Arie created a new library to explore what a better datetime
library could look like.None
so there is no way to distinguish between an explicit None
value and an unset field. This post explains how you process this scenario.Discussion:
Projects:
Additional Links:
Level up your Python skills with our expert-led courses: