Dataclasses in Python (Part-4) | post-init processing

preview_player
Показать описание
This video explains the concept of post-init processing in dataclasses.

#python #dataclasses

------------------------------------------------------------

More awesome topics covered here:

------------------------------------------------------------

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

Thank you sir, learnt so many new things

sureshgeddada
Автор

Hi Indian Pythonista,
thanks for these great tutorials on dataclasses.
For an assignment, I have to set each class variable to None if it is equal to "_".
How would you do that nicely? The only thing I've come up is to use __post_init__ and then check each class variable if it is "_" and then change accordingly. However, there are many class variables so I would like to do it more concisely.
Thanks!

evahoo
Автор

Does __post_init__ replace property decorator?

junfan
Автор

Hi, Why can't you use default_factory field function instead of post_init_processing ? I understand that default_factory field function doesn't take any arguments, but can't it refer to the co properties of the class to replace post_init_processing ?

ragamanjariponnaganti
visit shbcf.ru