0

I have an abstract class like so:

class SomeAbstract(object):
    __metaclass__ = ABCMeta

    @abstractproperty
    def one(self): pass

    @abstractproperty
    def two(self): pass

    @abstractproperty
    def three(self): pass

    ...

    @abstractmethod
    def somemethod(self): pass

    ...

Is there a way to designate all the properties and methods of an abstract class as abstract without having to put decorators on all of them?

1
  • If you don't have any implementations, why make it an ABC? An "interface", informal or enforced by a third party library dedicated to that use case, might be more suitable. Commented May 24, 2013 at 18:20

1 Answer 1

1

You could write a new metaclass that inherits from ABCMeta that makes all methods and properties abstract automatically, then use that metaclass in your class instead. You'll need to be careful to have some way to keep the behavior from propagating to classes that inherit from your abstract bases though.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.