In my code class A
has a property, but class B
doesn't inherit it. Does @property
support inheritance? Or is it my fault?
class A(object):
def __init__(self):
self._x = 100
@property
def x(self):
return self._x
@x.setter
def x(self, v):
self._x = v
class B(A):
@x.setter
def x(self, v):
self._x = v
The error message is as below:
Traceback (most recent call last):
File "test.py", line 9, in <module>
class B(A):
File "test.py", line 10, in B
@x.setter
NameError: name 'x' is not defined