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.
Course Spotlight: 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.
Topics:
namedtuple
News:
Show Links:
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.list
, dict
, and set
comprehensions as inline code can result in a 2x speedup on the comprehension.Discussion:
Projects:
Additional Links:
Level up your Python skills with our expert-led courses: