Sep-17-2020, 10:56 PM
Private not in Python,and use of getters/setters not at all for simple attribute access.
Then it can look this.
Then it can look this.
class Bil: def __init__(self, model, year): self.model = model self.year = year car = Bil('Fiat', 2017) print(f'Har nu skaffat mig en {car.model} av {car.year} års modell') # Setter(The Python way) car.year = 2020 print(f'Har nu skaffat mig en {car.model} av {car.year} års modell')
Output:Har nu skaffat mig en Fiat av 2017 års modell
Har nu skaffat mig en Fiat av 2020 års modell