

Discover more from Daily Dose of Data Science
High-quality insights on Data Science and Python, along with best practices — shared daily.
Get a free 550+ page data science PDF guide and 450+ practice questions notebook.
Over 49,000 subscribers
Continue reading
Make Dot Notation More Powerful in Python
Dot notation offers a simple and elegant way to access and modify the attributes of an instance.
Yet, it is a good programming practice to use the getter and setter method for such purposes. This is because it offers more control over how attributes are accessed/changed.
To leverage both in Python, use the @𝐩𝐫𝐨𝐩𝐞𝐫𝐭𝐲 decorator. As a result, you can use the dot notation and still have explicit control over how attributes are accessed/set.
Share this post on LinkedIn: Post 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.