Sveriges mest populära poddar

The Real Python Podcast

Coding With namedtuple & Python's Dynamic Superpowers

53 min • 17 mars 2023

Have you explored Python’s collections module? Within it, you’ll find a powerful factory function called namedtuple(), which provides multiple enhancements over the standard tuple for writing clearer and cleaner code. This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder’s Weekly articles and projects.

Christopher discusses his Real Python video course about writing more Pythonic code using namedtuple(). With namedtuple(), you can create immutable sequence types that allow you to access their values using descriptive field names and dot notation instead of clunky integer indices.

We also discuss metaprogramming and the unique advantages of Python’s dynamism. Christopher shares potential paths for this type of coding from web applications, testing, and AST techniques.

We share several other articles and projects from the Python community, including a news update, the Arrow revolution happening in pandas 2.0, a new PEP for inlined comprehensions, tips and techniques for modern Flask apps, a Python helper tool for building and running a REPL with custom commands, and a project to turn a pandas DataFrame into a Tableau-style UI.

Topics:

  • 00:00:00 – Introduction
  • 00:02:17 – Python 3.12.0 alpha 6 released
  • 00:02:40 – Django Developers Survey 2022 Results
  • 00:03:12 – Writing Clean, Pythonic Code With namedtuple
  • 00:07:40 – pandas 2.0 and the Arrow Revolution (Part I)
  • 00:17:21 – Sponsor: RevSys
  • 00:18:10 – PEP 709: Inlined Comprehensions
  • 00:20:51 – 13 Tips and Techniques for Modern Flask Apps
  • 00:25:54 – Video Course Spotlight
  • 00:27:24 – Discussion: Python’s “Disappointing” Superpowers
  • 00:47:54 – replbuilder: Python helper tool for building and running a REPL with custom commands
  • 00:49:58 – pygwalker: Turn pandas Into a Tableau-Style UI
  • 00:52:15 – Thanks and goodbye

News:

Show Links:

  • Writing Clean, Pythonic Code With namedtuple – In this video course, you’ll learn what Python’s namedtuple is and how to use it in your code. You’ll also learn about the main differences between named tuples and other data structures, such as dictionaries, data classes, and typed named tuples.
  • pandas 2.0 and the Arrow Revolution (Part I) – This article details the changes in the pandas 2.0 release, with emphasis on the underlying adoption of Apache Arrow.
  • PEP 709: Inlined Comprehensions – Python Enhancement Proposal 709 covers a change to how comprehensions are handled. Currently, they’re compiled as nested functions. Benchmarking shows that treating list, dict, and set comprehensions as inline code can result in a 2x speedup on the comprehension.
  • 13 Tips and Techniques for Modern Flask Apps – Flask is approaching its 13th birthday, and to celebrate, Phillip has written 13 tips for writing modern Flask apps. It covers dealing with JSON, environment-based configuration, auto-generated docs, and more.

Discussion:

Projects:

Additional Links:

Level up your Python skills with our expert-led courses:

Support the podcast & join our community of Pythonistas

Kategorier
Förekommer på
00:00 -00:00