Course Content
Object-Oriented Programming in Python
Get and Set
Getter and setter are methods for non-direct access to the attributes:
get()
(getter) returns the value of the private attribute;set()
(setter) sets the value.
These methods are called properties.
You can implement them by defining two additional methods:
Note
We added data validation inside the set_age()
method. Only the correct integer value can be assigned to the attribute.
Section 2.
Chapter 2