My class hierarchy looks like:
- Foo_ABC # abstract base class
- Baz_ABC # abstract base class
- Baz1
- Baz2
- Bar
...
Baz_ABC
defines an abstractproperty thing
, but also implements the setter @thing.setter
because the code is the same for both Baz1
and Baz2
. Yet in my tests I cannot set thing
:
>>> b = baz1()
>>> b.thing = 42
AttributeError: "can't set attribute" on b.thing
Simply moving @thing.setter
to the subclasses Baz1
and Baz2
resolves this. Why? Yes I know I can call super
from the subclasses. But I want to know why Python requires the class to define both the getter and setter.