class human(object):
def __init__(self, name=''):
self.name = name
@property
def name(self):
return self._name
@name.setter
def name(self, value):
self._name = value
class superhuman(human):
@property
def name(self):
return 'super ' + name
s = superhuman('john')
print s.name
# Doesn't work :( "AttributeError: can't set attribute"
s.name = 'jack'
print s.name
我希望能够覆盖该属性,但能够使用超级父级的设置器,而不必覆盖子类中的设置器。
这可能吗?