Artwork

Nội dung được cung cấp bởi Real Python. Tất cả nội dung podcast bao gồm các tập, đồ họa và mô tả podcast đều được Real Python hoặc đối tác nền tảng podcast của họ tải lên và cung cấp trực tiếp. Nếu bạn cho rằng ai đó đang sử dụng tác phẩm có bản quyền của bạn mà không có sự cho phép của bạn, bạn có thể làm theo quy trình được nêu ở đây https://vi.player.fm/legal.
Player FM - Ứng dụng Podcast
Chuyển sang chế độ ngoại tuyến với ứng dụng Player FM !

Practical Python Decorator Uses & Avoiding datetime Pitfalls

57:00
 
Chia sẻ
 

Manage episode 401279490 series 2637014
Nội dung được cung cấp bởi Real Python. Tất cả nội dung podcast bao gồm các tập, đồ họa và mô tả podcast đều được Real Python hoặc đối tác nền tảng podcast của họ tải lên và cung cấp trực tiếp. Nếu bạn cho rằng ai đó đang sử dụng tác phẩm có bản quyền của bạn mà không có sự cho phép của bạn, bạn có thể làm theo quy trình được nêu ở đây https://vi.player.fm/legal.

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:

  • 00:00:00 – Introduction
  • 00:02:53 – Django security releases issued: 5.0.2, 4.2.10, and 3.2.24
  • 00:03:10 – Python 3.12.2 and 3.11.8 are now available
  • 00:03:21 – Introducing PSF Grants Program Office Hours
  • 00:04:19 – Python’s Format Mini-Language for Tidy Strings
  • 00:12:22 – Ten Python datetime Pitfalls
  • 00:18:34 – Sponsor: Sentry
  • 00:19:37 – Real Life Use of Decorators
  • 00:29:18 – Handling Unset Values in FastAPI With Pydantic
  • 00:35:43 – Video Course Spotlight
  • 00:37:06 – The Python Rust-Aissance
  • 00:50:19 – django-mock-queries: Mock Django Queryset Functions
  • 00:53:09 – niquests: Requests but Multiplexed
  • 00:55:55 – Thanks and goodbye

News:

Show Links:

  • Python’s Format Mini-Language for Tidy Strings – In this tutorial, you’ll learn about Python’s format mini-language. See how to use it for creating working format specifiers and build nicely formatted strings and messages in your code.
  • Ten Python 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.
  • Real Life Use of Decorators – Part 3 in a series on how Python decorators are used. This part covers real-life use cases including call interception, function registration, and behavioral enrichment.
  • Handling Unset Values in FastAPI With Pydantic – When using the HTTP PATCH method only those fields that got changed are updated. Pydantic sets fields not given as arguments as 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:

Support the podcast & join our community of Pythonistas

  continue reading

278 tập

Artwork
iconChia sẻ
 
Manage episode 401279490 series 2637014
Nội dung được cung cấp bởi Real Python. Tất cả nội dung podcast bao gồm các tập, đồ họa và mô tả podcast đều được Real Python hoặc đối tác nền tảng podcast của họ tải lên và cung cấp trực tiếp. Nếu bạn cho rằng ai đó đang sử dụng tác phẩm có bản quyền của bạn mà không có sự cho phép của bạn, bạn có thể làm theo quy trình được nêu ở đây https://vi.player.fm/legal.

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:

  • 00:00:00 – Introduction
  • 00:02:53 – Django security releases issued: 5.0.2, 4.2.10, and 3.2.24
  • 00:03:10 – Python 3.12.2 and 3.11.8 are now available
  • 00:03:21 – Introducing PSF Grants Program Office Hours
  • 00:04:19 – Python’s Format Mini-Language for Tidy Strings
  • 00:12:22 – Ten Python datetime Pitfalls
  • 00:18:34 – Sponsor: Sentry
  • 00:19:37 – Real Life Use of Decorators
  • 00:29:18 – Handling Unset Values in FastAPI With Pydantic
  • 00:35:43 – Video Course Spotlight
  • 00:37:06 – The Python Rust-Aissance
  • 00:50:19 – django-mock-queries: Mock Django Queryset Functions
  • 00:53:09 – niquests: Requests but Multiplexed
  • 00:55:55 – Thanks and goodbye

News:

Show Links:

  • Python’s Format Mini-Language for Tidy Strings – In this tutorial, you’ll learn about Python’s format mini-language. See how to use it for creating working format specifiers and build nicely formatted strings and messages in your code.
  • Ten Python 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.
  • Real Life Use of Decorators – Part 3 in a series on how Python decorators are used. This part covers real-life use cases including call interception, function registration, and behavioral enrichment.
  • Handling Unset Values in FastAPI With Pydantic – When using the HTTP PATCH method only those fields that got changed are updated. Pydantic sets fields not given as arguments as 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:

Support the podcast & join our community of Pythonistas

  continue reading

278 tập

모든 에피소드

×
 
Loading …

Chào mừng bạn đến với Player FM!

Player FM đang quét trang web để tìm các podcast chất lượng cao cho bạn thưởng thức ngay bây giờ. Đây là ứng dụng podcast tốt nhất và hoạt động trên Android, iPhone và web. Đăng ký để đồng bộ các theo dõi trên tất cả thiết bị.

 

Hướng dẫn sử dụng nhanh

Nghe chương trình này trong khi bạn khám phá
Nghe