Use namedtuples for more readable code

preview_player
Показать описание
Most of you are familiar with tuples, but have you heard of their twin namedtuples as well (collections module)?

They let you accomplish the same thing but in a much nicer way.

In this short intro video we compare them with tuples, creating one and access its elements by attribute lookup.

We hope you will refactor tuples to namedtuples soon :)

Python docs:

PyBites exercises that use them:
Рекомендации по теме
Комментарии
Автор

Awesome video! Is there a reason to use named tuples over a dictionary besides the fact that named tuples are immutable?

raymonddevries