Writing Pythonic code is an in-demand skill in the Python development space. Pythonic code is readable, explicit, clean, maintainable, and takes advantage of Python idioms and best practices. In this video course, you learned about creating namedtuple
classes and instances and how they can help you improve the quality of your Python code.
In this video course, you learned:
- How to create and use
namedtuple
classes and instances - How to take advantage of cool
namedtuple
features - When to use
namedtuple
instances to write Pythonic code - When to use a
namedtuple
instead of a similar data structure - How to subclass a
namedtuple
to add new features
With this knowledge, you can deeply improve the quality of your existing and future code. If you frequently use tuples, then consider turning them into named tuples whenever it makes sense. Doing so will make your code much more readable and Pythonic.
To learn more about the concepts in this course, check out the following resources:
- Python named tuple documentation
- Memory Profiling Python with pympler
- Python Timer Functions: Three Ways to Monitor Your Code
- Lists and Tuples in Python
- Common Python Data Structures (Guide)
You can also take the following Real Python video courses:
- Lists and Tuples in Python
- Stacks and Queues: Selecting the Ideal Data Structure
- Dictionaries and Arrays: Selecting the Ideal Data Structure
- Records and Sets: Selecting the Ideal Data Structure
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.