

Discover more from Daily Dose of Data Science
High-quality insights on Data Science and Python, along with best practices — shared daily.
Get a 550+ Page Data Science PDF Guide and 450+ Practice Questions Notebook, FREE.
Over 36,000 subscribers
Continue reading
__Post_init__: Add Attributes To A Dataclass Object Post Initialization
After initializing a class object, we often create derived attributes from existing variables.
To do this in dataclasses, you can use the __𝐩𝐨𝐬𝐭_𝐢𝐧𝐢𝐭__ method. As the name suggests, this method is invoked right after the __𝐢𝐧𝐢𝐭__ method.
This is useful if you need to perform additional setups on your dataclass instance.
Share this post on LinkedIn: Link.
Find the code for my tips here: GitHub.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.