How define constructor implementation for an Abstract Class in Python?

前端 未结 5 1167
难免孤独
难免孤独 2020-12-29 01:32

I am trying to declare an abstract class A with a constructor with a default behavior: all subclasses must initialize a member self.n:



        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 01:59

    You should define the methods as abstract as well with the @abc.abstractmethod decorator.

提交回复
热议问题