kak*_*kyo 0 python import exception
我有这样一个类似接口的函数:
# 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
Run Code Online (Sandbox Code Playgroud)
现在,当我导入此模块时,我立即得到NotImplementedError,因此我无法使用SimpleParser.我怎么能使用这个例外习惯用法仍然可以使用它?
谢谢!
| 归档时间: |
|
| 查看次数: |
51 次 |
| 最近记录: |