相关疑难解决方法(0)

Python中的抽象方法

我需要像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)会改进吗?

python oop abstract-class python-3.x

21
推荐指数
2
解决办法
2万
查看次数

标签 统计

abstract-class ×1

oop ×1

python ×1

python-3.x ×1