Since Python strives for there to be one right way, I'm wondering what the purpose of property.getter is. In this example WhyMe defines a getter but Other doesn't so I'm wondering what the point of property.getter is over just using property.
class WhyMe(object):
def __init__(self):
self._val = 44
@property
def val(self):
print 'I am not called'
return self._val
@val.getter # What advantage do I bring?
def val(self):
print 'getter called'
return self._val
class Other(object):
def __init__(self):
self._val = 44
@property
def val(self):
print 'I AM called'
return self._val
And using them:
>>> why = WhyMe()
>>> why.val
getter called
44
>>> other = Other()
>>> other.val
I AM called
44
I'm no stranger to properties, I'm just wondering if there is some advantage to making a getter or if was just put there for symmetry?