我需要像abstract protectedPython(3.2)中的方法:
class Abstract:
def use_concrete_implementation(self):
print(self._concrete_method())
def _concrete_method(self):
raise NotImplementedError()
class Concrete(Abstract):
def _concrete_method(self):
return 2 * 3
Run Code Online (Sandbox Code Playgroud)
为了引发NotImplementedError,定义"抽象"方法实际上是否有用?
对于抽象方法使用下划线是否是好的风格,那将是protected其他语言?
抽象基类(abc)会改进吗?