Data Classes In Less Than A Minute // Python Tips

preview_player
Показать описание


#arjancodes #softwaredesign #python
Рекомендации по теме
Комментарии
Автор

Also, the ease of using slots instead of a dict is a big win!

chriskorfmann
Автор

Hi Arjan. It would be nice if you could clear your terminal before printing as it's very hard to see where the statement was printed because of so many things in the terminal.
Cheers.

gamemoves
Автор

@Arjan I would've expanded on the setter method of changing a value on the dataclass with setattr(<dataclass>, <attribute>, <value>) .
And also converting the Dataclass back into a dictionary with
Dataclasses are excellent at describing nested classes and having typehinting. Only native shortcoming is manual unpacking of dict to dataclass objects.
*edit* wrote class instead of dataclass in last sentence 🤫

CaddyBlue
Автор

I think the only thing that confuses me is for a data scientist that doesn't write too many classes like myself: should these things replace a config json file or a dictionary, and if so why?

DistortedV
Автор

When should we use frozen dataclasses versus NamedTuples if we want immutable objects?

xLL
Автор

Question, are the instance variables here only a class attribute now? Before, with the init, the self. for each instance made it a class instance variable. Normally when we do that without the self. outside the init of the class, it is an attribute. Typically that means that the instance of that class (the objects made from the class) will all share the same variables. Does dataclass prevent this from being a class attribute?

StalkedByLosers
Автор

Is data classes always better than traditional classes?

tanjt
visit shbcf.ru