class A(object):
def __init__(self, x):
self.x = x
def _get_y(self):
return self.x * 2
y = property(_get_y)
def _get_z(self):
return self.x * 2
def __get_z(self):
return self._get_z()
z = property(__get_z)
class B(A):
def _get_y(self):
return self.x * 3
#y = property(_get_y)
def _get_z(self):
return self.x * 3
a, b = A(1), B(1)
print(a.y, b.y)
print(a.z, b.z)
print(type(B.y))
Item 31: Property Override
Posted by Logan Chien