filmov
tv
Python: Create Classes with Named Tuple (namedtuple) Using Typing

Показать описание
#Shorts #Python
Python Tips and Tricks:
We already know how to use namedtuple to create classes in Python if they're simple enough and we want to reduce the amount of code we have to write. But what about all those arguments being nothing else than a string? Surely it's more prone to errors and typos. That's why I prefer to use namedtuple from the "typing" module! There are a couple of ways to do that and one is better than another (in my opinion).
-------------------------------------------------------------------------------------
Links:
Python Tips and Tricks:
We already know how to use namedtuple to create classes in Python if they're simple enough and we want to reduce the amount of code we have to write. But what about all those arguments being nothing else than a string? Surely it's more prone to errors and typos. That's why I prefer to use namedtuple from the "typing" module! There are a couple of ways to do that and one is better than another (in my opinion).
-------------------------------------------------------------------------------------
Links: