Preventing a class from direct instantiation in Python

后端 未结 4 2051
春和景丽
春和景丽 2020-12-24 11:52

I have a super class with a method that calls other methods that are only defined in its sub classes. That\'s why, when I create an instance of my super class and call its m

4条回答
  •  -上瘾入骨i
    2020-12-24 12:30

    You're talking about Abstract Base Classes, and the Python language does not support them natively.

    However, in the standard library, there is a module you can use to help you along. Check out the abc documentation.

提交回复
热议问题