In python, can I define an interface (abstract class) by inheritance from another abstract class? If I try:
import abc
ABC = abc.ABCMeta('ABC', (object,), {})
class interface(ABC):
@abc.abstractmethod
def method(self, message):
return
class InterfaceExtended(ABC, interface):
@abc.abstractmethod
def NewMethod(self, message):
return
I get an error on the "InterfaceExtended" class :
TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution
order (MRO) for bases ABC, Interface
Don't inherit from ABC in your second class. The interface it derives from already inherits ABC
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.