Python Glossary Русский

Python 3.2+deprecated in 3.3abcterm

abc.abstractstaticmethod

abstract classes

Deprecated: an abstract staticmethod. Use @staticmethod on top of @abstractmethod.

Syntax

@abc.abstractstaticmethod  # deprecated

It exists for historical reasons: before Python 3.3 a plain staticmethod dropped the abstractness flag, so separate wrappers were needed. Today staticmethod propagates __isabstractmethod__ itself, so you stack two decorators instead — and the order matters: @staticmethod goes on top, @abstractmethod closest to the function.

Examples

import abc
print(callable(abc.abstractstaticmethod))   # → True
print(issubclass(abc.abstractstaticmethod, staticmethod))   # → True
import abc
class Base(abc.ABC): make = abc.abstractstaticmethod(lambda: 1)
print(Base.__abstractmethods__)   # → frozenset({'make'})
print(Base())   # → TypeError (не реализован make)

See also

Open in the full glossarydocs.python.orgReport an inaccuracy