小编bio*_*iwi的帖子

Python导入所有导入另一个相同模块的模块

我想要的是,我有foo.py它从bar1,bar2导入类,他们都需要bar3,例如

foo.py

from src import *
...
Run Code Online (Sandbox Code Playgroud)

src/__ init__.py

from bar1 import specialSandwichMaker
from bar2 import specialMuffinMaker
Run Code Online (Sandbox Code Playgroud)

SRC/bar1.py

import bar3
class specialSandwichMaker(bar3.sandwichMaker)
...
Run Code Online (Sandbox Code Playgroud)

SRC/bar2.py

import bar3
class specialMuffinMaker(bar3.muffinMaker)
...
Run Code Online (Sandbox Code Playgroud)

是否有更有效的方法使bar3可用于bar1和bar2文件,而无需直接导入它?

python

4
推荐指数
1
解决办法
8087
查看次数

标签 统计

python ×1