python: 4 ways to set namedtuple defaults (intermediate) anthony explains #118

preview_player
Показать описание
today I talk about four different strategies for setting default values on namedtuple construction! there's different patterns to choose depending on what version of python you need to support / other requirements

==========

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!
Рекомендации по теме
Комментарии
Автор

I know you mentioned in videos the difference between NameTuple and dataclass but I still think I needs it's own video. Special when to pick one over the other.

GOZES
Автор

It would be cool if you could do a video on how to implement NamedTuple with metaclasses. Thanks!

tib
Автор

Thanks for the video :)
could you pls explain how to get a user input in to that?
For c4(x, y, z) example here, I tried: c4._make(list(map(int, input().split()))). with 3 args (like: 10, 11, 12) it got it well, but with less args (like 2: 10, 11) when wish to get the default values - it raised an error for missing args.
Thank you

lilacgolan
Автор

with typing named tuple, i cant omit the type annotation even if i provide a default value of a field right? any good reason for that?

sadhlife