Learn Python - Properties

Опубликовано: 20 Март 2026
на канале: Tech Programmer
50
1

In Python, we need to set the private members to hide the implementation of our private members, but we have to then define the getter and setter methods to retrieve and set them. Setter method may be useful even to have a custom logic before we set the value of an attribute.

This video shows a practical example of how we can implement custom logic while setting an attribute. This first validates the data provided by the user and then if it is valid, it will set it else it throws an exception.

This video further goes into Python properties. There are several options to create property in Python objects. We could use property built-in function to create a property, but there is even cleaner way to code properties. We could use property decorators for this purpose. This video show exactly how you can do this.

If you like our content, click on SUBSCRIBE button and click on Bell icon to receive latest and greatest updates of my video lessons.

Follow us on Facebook, Twitter, Instagram

Facebook Link:   / techprogrammer1  
Twitter Link:   / techprogrammer1  
Tumblr Blog: https://www.tumblr.com/blog/techprogr...