Say I have this structure.
MyApp ├── main.py └── package ├── __init__.py ├── a.py ├── b.py ├── c.py ├── d.py ├── e.py ├── f.py ├── g.py ├── h.py ├── ... └── z.py
And in main.py I need to use all modules, from a.py to z.py
I would like to know how I can import all of these modules with a single import statement.
So, instead of doing
from package import a from package import b ... from package import z
I could just import the package and prepare all the modules.
What i tried
import package a = package.aA()
Now I know that I can put the code in __init__.py to add all the modules to __all__ , but from what I read, we should avoid "from package import"
The reason for this is that a package can have an increasing number of modules, and I would like to add an import statement to the main code every time a module is created. Ideally, I would just leave the module in the package and prepare it for use.
sqram source share