In my Python app I want to make a method that is both a staticmethod
and an abc.abstractmethod
. How do I do this?
I tried applying both decorators, but it doesn't work. If I do this:
import abcclass C(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod @staticmethod def my_function(): pass
I get an exception*, and if I do this:
class C(object): __metaclass__ = abc.ABCMeta @staticmethod @abc.abstractmethod def my_function(): pass
The abstract method is not enforced.
How can I make an abstract static method?
*The exception:
File "c:\Python26\Lib\abc.py", line 29, in abstractmethod funcobj.__isabstractmethod__ = TrueAttributeError: 'staticmethod' object has no attribute '__isabstractmethod__'