Discover more from Daily Dose of Data Science
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.
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.
Find the code for my tips here: GitHub.