On an abstract class, in Python 3.6+, I'm trying to define a class property that is derived from other (abstract) class properties.
What I've tried:
from abc import abstractmethod
class AbstractAnimal:
@classmethod
@property
@abstractmethod
def front_limbs(cls):
raise NotImplementedError
@classmethod
@property
@abstractmethod
def back_limbs(cls):
raise NotImplementedError
@classmethod
@property
def limbs(cls):
return [cls.front_limbs, cls.back_limbs]
class Monkey(AbstractAnimal):
front_limbs = 'arms'
back_limbs = 'legs'
print(Monkey.front_limbs)
print(Monkey.back_limbs)
print(Monkey.limbs)
I expect/desire:
arms
legs
[arms, legs]
I get:
arms
legs
<bound method ? of <class '__main__.Monkey'>>
I tried looking at previous questions, as this feels pretty basic, but none of them discussed derived class properties (this one, for example, helped me with abstract properties to begin with).