我有一个关于@property我在以下代码中看到的装饰器的问题.有人能够完全解释为什么有人会使用@property装饰器吗?我知道@property等价isActive = property(isActive)但是方法属性实际对它的参数做了什么?如果我isActive从InputCell课堂上调用这个方法会发生什么?提前致谢.
class InputCell(object):
def __init__(self, ix, iy, inputData):
self.ix = ix
self.iy = iy
self.InputData = inputData
@property
def isActive(self):
return self.InputData[self.ix][self.iy]
Run Code Online (Sandbox Code Playgroud)