intro to python namedtuples! (beginner - intermediate) anthony explains #100

preview_player
Показать описание
oh hey, it's episode 100! today I talk about one of my favorite ways to make plain-old-data classes in python!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

Congratz on your 100th video of anthony explains!

Aucacoyan
Автор

I saw the merge request with a video on flake8 and came to check your youtube channel :) Nicely done ! Just a little nitpick, I think the print_me function should be a _str_ and then instead of user.print_me() the loop would be print(user).

PierreSassoulas
Автор

I like the 'Carmen' easter egg!

JakubYTb
Автор

So they look basically identical to dataclasses but can be chosen over dataclasses when immutability is needed

GabrieleBonetti
Автор

The initial form was possible to write as a one liner, which is not the case of the later one !

optimiserlenergie
Автор

If you wanted to have a mutable default argument like a List for a NamedTuple, how would you go about doing it?
I'd use `field(default_factory=list)` if I were using a dataclass.

_gunna
Автор

ok that's actually pretty hot

i do wonder what's actually happening here, what dunder method is being run when i do xyz: Type?

sadhlife
Автор

is there a good reason to inherit NamedTuple instead of a decorating with dataclass?

sopidf
Автор

how is this different from @dataclass?

euclitian
Автор

The typing.NamedTuple is better, with improved syntax.

gedtoon
Автор

What type is get_users returning? A list of namedtuples?

ShivanS