假设我创建了一个类:
class SomeClass:
def __init__(self, some_attribute):
self._attribute = some_attribute
@property
def attribute(self):
return self._attribute
接下来,我给我的对象添加了一个名为new_method
的方法,该方法将使用“attribute”。
因此,我应该使用self._attribute
还是self.attribute
?
def new_method(self):
DoSomething(self.attribute) # or DoSomething(self._attribute)
这会产生任何影响或差异吗?