tech:notes_python_-_les_objects_-_class
Notes Python - les objects - Class
Exemples
class Geeks: def __init__(self): self._age = 0 # using property decorator # a getter function @property def age(self): print("getter method called") return self._age # a setter function @age.setter def age(self, a): if(a < 18): raise ValueError("Sorry you age is below eligibility criteria") print("setter method called") self._age = a mark = Geeks() mark.age = 19 print(mark.age)
Source : https://www.geeksforgeeks.org/getter-and-setter-in-python/
tech/notes_python_-_les_objects_-_class.txt · Dernière modification : de 127.0.0.1
