在python中创建模块-导入如何工作
我正在python应用程序中创建一个模块,我有我的主代码文件,我想从helper文件夹导入一些helper方法/类。这是我的文件夹结构:在python中创建模块-导入如何工作,python,module,Python,Module,我正在python应用程序中创建一个模块,我有我的主代码文件,我想从helper文件夹导入一些helper方法/类。这是我的文件夹结构: module: __init__.py helpers: __init__.py some_class.py 这是module/helpers/\uuuuuu init\uuuuu.py文件: from .some_class import SomeClass def helper_method_1(): # cod
module:
__init__.py
helpers:
__init__.py
some_class.py
这是module/helpers/\uuuuuu init\uuuuu.py
文件:
from .some_class import SomeClass
def helper_method_1():
# code
def helper_method_2():
# code
所以我的问题是:在helpers
中导入SomeClass
模块/helpers/\uuu init\uuuuuuuuuuuupy是否足以在我的主模块/uuuuu init.py
文件中使用它作为导入
这就是我在模块/\uuu init\uuuuuuuuupy中尝试的内容
from .helpers import (SomeClass, helper_method_1, helper_method_2)
我有点在做一堆事情,所以现在不能测试它的错误, < P>是的,就足够了。
除非模块具有\uuuuuuuuuuuuuuuuuuuuuuuuuu
变量,否则将导出所有名称(包括从其他模块导入的名称)