1
我有這樣描述:的Python - 添加屬性描述
# Generic descriptor
class Attribute(object):
def __init__(self, value):
self.value = value
def __get__(self, instance, value):
return self.value
def __set__(self, instance, value):
self.value = value
我想補充的屬性「修改」檢查描述符的情況下被修改。 ES。
# Generic descriptor
class Attribute(object):
def __init__(self, value):
self.value = value
self.modified = False
def __get__(self, instance, value):
return self.value
def __set__(self, instance, value):
self.value = value
self.modified = True
我該怎麼做?