i was looking into properties and could not understand the use of getter.
Code :
class A:
def __init__(self,p):
self._p = p
@property
def p(self):
return self._p
@p.setter
def p(self, value):
self._p = value
@p.getter
def p(self):
return self._p
so,i did the following
obj = A(10)
print(obj.p)
i got the following output:
10
So, i thought, @p.getter is called and the value of _q is returned.
But, i tried without @p.getter as below
class A:
def __init__(self,p):
self._p = p
@property
def p(self):
return self._p
@p.setter
def p(self, value):
self._p = value
And did the following
obj = A(10)
print(obj.p)
and even then i got the following output:
10
So, i was wondering, what is the actual use of @p.getter here, when @property it self was able to give us the value of _q