Python 3.2+deprecated in 3.3abcterm
abc.abstractclassmethod
abstract classes
Deprecated: an abstract classmethod. Use @classmethod on top of @abstractmethod.
Syntax
@abc.abstractclassmethod # deprecated
This wrapper dates back to a time when classmethod could not propagate the abstractness flag; since Python 3.3 stacking @classmethod on top of @abstractmethod does the same job, and the separate decorator has been deprecated ever since. It survives in the standard library purely for old code — do not reach for it in anything new.
Examples
import abc
print(callable(abc.abstractclassmethod)) # → True
print(issubclass(abc.abstractclassmethod, classmethod)) # → True
import abc
class Base(abc.ABC):
@abc.abstractclassmethod
def create(cls): ...
print(Base.__abstractmethods__) # → frozenset({'create'})
class Modern(abc.ABC):
@classmethod
@abc.abstractmethod
def create(cls): ...
print(Modern.__abstractmethods__) # → frozenset({'create'})
print(Base()) # → TypeError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy