I have a “partial” class that requires some mixin for its functionality (I want to do it with inheritance for performance and simplicity reasons). Can I declare that my class is going to need new methods?
Apparently the following guess does not work (“Can’t instantiate abstract class”):
from abc import abstractmethod, ABCMeta
class A(metaclass=ABCMeta):
@abstractmethod
def a(self):
pass
class B:
def a(self):
return 12
class C(A, B):
pass
c = C()
Here A tries to declare that its other methods need a() to work.
(Python 3)
Any suggestions to the declare that?
You need to put
Bin front ofAin the inheritance order for that to work: