__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.
Thanks for reading Daily Dose of Data Science! Subscribe for free to receive new posts and support my work.
Find the code for my tips here: GitHub.