Folder structure
GitHub Repo
Practical project
Folders
βββ Folder1
β βββ subFolder1
β β βββ File2.py
β βββ File1.py
β βββ MainFile.py
βββ Folder2
βββ subFolder3
βββ File3.py
Main Folder is
Folders
Folders
-> contains 2 subFolder NameFolder1
&Folder2
Folder1
->subFolder1
&MainFile.py
Folder2
->subFolder3
->File3.py
subFolder1
->File1.py
&File2.py
To import File from different Folders
1. File in the same directory
MainFile.py
import File1
2. File in the sub directory
MainFile.py
from subFolder1 import File2
3. File in the 1 step back parent directory
File2.py
from ..MainFile import ClassName
4. File in the parent directory
MainFile.py
# You Can use this to import file from any directory
import sys
sys.path.insert(1,'C://Repo//temptodel//Folders//Folder2//subFolder3')
import File3
print(File3.f33)
Top comments (0)