Skip to content

Abstractclassmethod

Implementation of a new abstractclassmethod property.

abstractclassmethod

Bases: classmethod

Python 2.7 does not include built in @abstractclassmethod so we create our own class that extends @classmethod and then attaches a __isabstractmethod variable to the callable function. See ref: https://stackoverflow.com/a/11218474

Source code in maestrowf/abstracts/abstractclassmethod.py
class abstractclassmethod(classmethod):
    """Python 2.7 does not include built in @abstractclassmethod so we create
    our own class that extends @classmethod and then attaches a
    __isabstractmethod variable to the callable function. See ref:
    https://stackoverflow.com/a/11218474"""

    __isabstractmethod__ = True

    def __init__(self, callable):
        callable.__isabstractmethod__ = True
        super(abstractclassmethod, self).__init__(callable)