ABC还是zope.interface?

2024-05-16 20:16:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码:

class AppInterface(zope.interface.Interface):

    def required_function():
        pass

@zope.interface.implementer(AppInterface)
class DesktopApp:
    def other_function(self):
        print('Who I am')

我没有在DekstopApp中编写所需的函数,它必须引发错误。
但此代码是有效的。
但当我使用abc模块时,如果我没有编写所需的方法,我将得到一个错误

我应该使用abc还是zope.interface


Tags: 代码zopedef错误requiredfunctionpassinterface