what's difference python getter and setter?
Getters allow read-only access, setters can be used to validate the input. Here's an example: https://code.sololearn.com/crgz6d6tK4LN/?ref=app
A getter is used to get the value of a variable inside a class, while setters are used to modify value of that variables. Exemple : class Car: def __init__(self) : self.x = 0 def getterX(self) : return self.x def setterX(self, value) : self.x = value
More specifically what makes the setter?
Here, the setter changes the value of x... And that's all! It's used for encapsulation. We don't change directly the values of the variables from outside a class, but we use setters instead.