【发布时间】:2020-01-13 04:33:22
【问题描述】:
过去 4 小时我一直在这里追尾,找不到解决办法。
我的项目有以下模块/包结构。
.
├── app-cli.py
├── tools
│ ├── __init__.py
│ ├── adapters
│ │ ├── __init__.py
│ │ ├── cli.py
│ │ ├── web.py
│ ├── utils
│ │ ├── __init__.py
│ │ ├── core.py
│ │ │ ├── my_public_method()
│ │ ├── io.py
│ │ │ ├── some_other_public_method()
我要做的是将utils 内的所有内容捆绑在utils 名称空间内。
所以当我在主级别执行import tools 时,我可以访问 util 函数:
tools.utils.my_public_method()
tools.utils.some_other_public_method()
代替:
tools.utils.core.my_public_method()
tools.utils.io.some_other_public_method()
我一直在编辑__init__.py,弄乱了导入的级别,试图创建一个快捷方式但没有成功。
【问题讨论】: