zhanghaitao1
6/3/2019 - 12:34 PM

abc, ABCMeta, absractmethod

abc, ABCMeta, absractmethod


from abc import ABCMeta,abstractmethod

class Base (object,metaclass=ABCMeta):
    @abstractmethod
    def foo(self):
        pass

    @abstractmethod
    def bar(self):
        pass

class Concrete(Base):
    def foo(self):
        pass

     # We forget to declare 'bar'

c=Concrete() #TypeError: Can't instantiate abstract class Concrete with abstract methods bar