Import files contained in subfolders of a main folder, without specifying individual subfolder or file names

Viewed 26

I would like to import files contained in subfolders of a parent folder at the same time, without specifying the individual names of the subfolders or files. Is there a way to use the same path and import subfolders and related files of a parent folder?

I have the root folder where there is folder 1 (with file 1 inside), folder 2 (with file 2 inside), folder 3 (with file 3 inside)

Main
> Folder 1 >> File 1.py
> Folder 2 >> File 2.py
> Folder 3 >> File 3.py

So I would like to use File 1, File 2 and File 3, simply writing something like: import Main or from Main import *, I tried that, but it doesn't work.

The solution could be this, but I don't want to write like this, because I have 20-30 folders:

import Main.Folder1
import Main.Folder2
import Main.Folder3
0 Answers
Related