Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python getters and setters

class Car():
    def __init__(self):
        self._seat = None

    @property # getter
    def seat(self):
        return self._seat

    @seat.setter # setter
    def seat(self, seat):
        self._seat = seat


c = Car()
c.seat = 6
print(c.seat)
 
PREVIOUS NEXT
Tagged: #python #getters #setters
ADD COMMENT
Topic
Name
6+9 =