【发布时间】:2017-03-17 15:58:12
【问题描述】:
假设我有一个模块rules,其结构如下:
rules
├── conditions.py
├── __init__.py
在脚本conditions.py 中,我想导入一个在__init__.py 中定义的名为RuleParserError 的类。但是,我无法弄清楚如何做到这一点。 (按照Python: How to import from an __init__.py file?我试过了
from . import RuleParserError
但这会在尝试将conditions.py 运行为__main__ 时导致ImportError: cannot import name RuleParserError。
【问题讨论】:
标签: python