two brief question about abstractproperty

Darren Dale dsdale24 at gmail.com
Sat Mar 12 23:16:41 EST 2011


I've been reading PEP 3119 and the documentation for ABCs in the
python documentation. According to the PEP, the following should yield
an error, because the abstract property has not been overridden:

import abc
class C:
    __metaclass__ = abc.ABCMeta
    @abc.abstractproperty
    def x(self):
        return 1
c=C()

but an error is not raised, nor for the case where I do:

class D(C):
    pass
d=D()

Have I misunderstood the documentation? Why doesn't this raise an
error? I see the same behavior with the @abstractmethod.

Also, why isn't it possible to declare an abstract read/write property
with the decorator syntax:

class C:
    __metaclass__ = abc.ABCMeta
    @abc.abstractproperty
    def x(self):
        pass
    @x.setter
    def x(self, val):
        "this is also abstract"




More information about the Python-list mailing list