问题
I have a folder with structure like this (names are not real):
script0_1.py
script0_2.py
- folder1
- folder1_1
- script1_1_1.py
- script1_1_2.py
- folder1_2
- script1_2_1.py
- script1_2_2.py
- folder2
- script2_1.py
- folder3
...
Important moment is that the structure can be changed, scripts added, etc. I want to create a package, to be able to run commands like this
my_package.folder1.folder1_1.script1_1_1.some_func()
, easily. I know a bit that I can create __init__.py
in each folder, then import all function one by one, but maybe there is an easier way?
Also, I'm interested, how to import all function in the folders or subfolders, but not by importing them in __init__.py
one by one, for example if there is a function my_package.folder1.folder1_1.script1_1_1.some_func()
, I can use simply my_package.some_func()
来源:https://stackoverflow.com/questions/60052928/how-to-easily-create-python-package-keeping-the-folder-structure-and-files