0
App
ㄴCore
  ㄴ Controllers
     ㄴ working.py
     ㄴ Components
        ㄴ Elements
            ㄴAA.py
            ㄴAB.py
              (...)
            ㄴZZ.py
  ㄴ DTO
     ㄴH.py
     ㄴI.py
     ㄴk.py

ㄴConfig
 ㄴE.py
 ㄴF.py
ㄴDB
  ㄴdb.py
ㄴUtil
  ㄴutils.py

In the elements folder, import Config folder's python file and its classes
utils.py imported on most of all files.
In elements folder, there are many python files.
And, most of python files need to import classes in same directory's files.
And, most of python files need to import classes in DTO folders.
the python files in elements folder is imported hierarchically.

On my computer, it is not possible to register sys.path(app_directory) When I tried to import AA to AB

from AA import aa
This is not working.

So, I added __init__ in the components folder. And, importing AA to ZZ using __import__.
Then from AA import aa is working.
But, although I added app directory using sys.path.append on __init__, for instances, from app.DB.db import db, from core.DTO.H import h, from DTO.H import h, from H import h, from . import h is not working at python files in Elements folder.

I want to import necessary python files and classes.

nayang
  • 157
  • 1
  • 14
  • Does this answer your question? [How to load all modules in a folder?](https://stackoverflow.com/questions/1057431/how-to-load-all-modules-in-a-folder) – Xiddoc Sep 29 '21 at 17:31
  • @Xiddoc __init__ file in Controllers folder, I did How to load all modules in a folder? solution already, but in this case, the path for DTO or Config or DB folder is not found, so I can't import it. – nayang Sep 30 '21 at 02:31

0 Answers0