So I've read that you're supposed to access object attributes through getter/setter methods like object.get_this()
or object.set_that(value)
. Does this code hold for methods that are also defined within the class? Or they are only meant to be used with object instances. For instance, is it idiomatic to do it this way,
class test:
def __init__(self,value):
self.value = value
def get_value(self):
return self.value
def method(self):
return some_operation(self.value)
with get_value()
defined for accessing value
for an object instance, or should get_value()
also be used within class methods?
class test:
def __init__(self,value):
self.value = value
def get_value(self):
return self.value
def method(self):
return some_operation(self.get_value())