1# of get() and set() method in
2# normal function
3
4class Geek:
5 def __init__(self, age = 0):
6 self._age = age
7
8 # getter method
9 def get_age(self):
10 return self._age
11
12 # setter method
13 def set_age(self, x):
14 self._age = x
15
16raj = Geek()
17
18# setting the age using setter
19raj.set_age(21)
20
21# retrieving age using getter
22print(raj.get_age())
23
1c = C()
2c.x = 'foo' # setter called
3foo = c.x # getter called
4del c.x # deleter called