If you want greet
to be a property, you still need to use the @property
decorator in your implementation:
class Foo(FooBase):
@property
def greet(self):
return 'hello'
All that an ABC metaclass does is test wether or not you have provided the same name in the concrete class; it doesn't care if it is a method or a property or a regular attribute.
Because it doesn't care, it doesn't magically apply property
decorators either. This is a good thing; perhaps in a specific implementation a static attribute is enough to satisfy the requirement, and a property would be overkill.
The purpose of a ABC metaclass is to help you detect gaps in your implementation; it never was intended to enforce the types of the attributes.
Note that before Python 3.3 you can not combine a @property
with an @abstractmethod
. You would have to use an @abstractproperty
decorator instead. There is an ambiguity there when your property needs more than a simple getter in that case; Python 3.3 covers that case much better (see issue 11610 for the painful details).