This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dsdale24
Recipients dsdale24
Date 2011-03-19.18:49:09
SpamBayes Score 1.2316587e-10
Marked as misclassified No
Message-id <>
I posted a suggestion at python-ideas that the declaration of abstract properties could be improved in such a way that they could be declared with either the long-form or decorator syntax using the built-in property and abc.abstractmethod:

class MyProperty(property):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for f in (self.fget, self.fset, self.fdel):
            if getattr(f, '__isabstractmethod__', False):
                self.__isabstractmethod__ = True

class C(metaclass=ABCMeta):
    def x(self):
    def x(self, val):

    # this syntax would also be supported:
    #def getx(self):
    #    pass
    #def setx(self, val):
    #    pass
    #x = MyProperty(getx, setx)

class D(C):
    'D does not define a concrete setter and cannot be instantiated'
    def x(self):
        return 1

class E(D):
    'E has a concrete getter and setter, and can be instantiated'
    def x(self, val):

It is hopefully evident that a relatively minor extension can be made to the built-in property such that @abstractproperty would no longer be needed. I have prepared a patch, complete with documentation and unit tests, but unfortunately I have not been able to test it because I have not been able to build Python from a mercurial checkout on either Ubuntu 11.04 or OS X 10.6.6 (for reasons unrelated to the patch.) BDFL thought the idea sounded good for inclusion in Python-3.3, and requested I submit the patch here.
Date User Action Args
2011-03-19 18:49:11dsdale24setrecipients: + dsdale24
2011-03-19 18:49:11dsdale24setmessageid: <>
2011-03-19 18:49:11dsdale24linkissue11610 messages
2011-03-19 18:49:10dsdale24create