我有一个类似接口的函数,它是这样实现的:
# File: parsers.py
class BaseParser(object):
'''Interface class'''
def __init__(self):
self.content
def Parse(self):
"""The interface, not implemented"""
raise NotImplementedError('{}.Parse()'.format(inspect.stack()[0][3]))
class SimpleParser(BaseParser):
'''Implementation class'''
def __init__(self):
BaseParser.__init__(self)
def Parse(self):
# Do real work
现在,当我导入这个模块时,我马上得到NotImplementedError,所以我不能使用SimpleParser。 我怎样才能使用这个异常习语并且仍然能够使用它呢?你知道吗
谢谢!你知道吗
你的缩进是错误的,混合了空格和制表符。使用
python -tt
验证。你知道吗相关问题 更多 >
编程相关推荐