Is it possible to have an abstract class inherit abstract methods from another abstract class in python?
If so, how should I do this?
Have a look at abc
module. For 2.7: link. For 3.6: link Simple example for you:
from abc import ABC, abstractmethod
class A(ABC):
def __init__(self, value):
self.value = value
super().__init__()
@abstractmethod
def do_something(self):
pass
class B(A):
@abstractmethod
def do_something_else(self):
pass
class C(B):
def do_something(self):
pass
def do_something_else(self):
pass
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments