Possible Duplicate:
Real world example about how to use property feature in python?
I have a question about the decorator @property
that I've seen in the following code. Could someone be kind enough to completely explain why someone would use the @property
decorator? I know @property
is equivalent to isActive = property(isActive)
but what does the method property actually do to it's parameter? If I were to call the isActive
method from the InputCell
class what would actually happen? Thanks in advance.
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]