Reputation: 344
I have such structure of application
mainApp.py
|_Folder1
|_fileFromFolder1.py
|_Folder2
|_fileFromFolder2.py
I want in fileFromFolder1.py import object from fileFromFolder2.py
I know that one of solution is to sys.path.insert(0, '/path/to/application/app/folder') but is it possible to make without absolute path
Upvotes: 0
Views: 144
Reputation: 17516
You need(not strictly need in Python3, but still really really should have) __init__.py
files in directories you would like to import code from. An __init__.py
file makes the difference between a plain directory and a Python package
mainApp.py
|_Folder1
|__init__.py
|_fileFromFolder1.py
|_Folder2
|__init__.py
|_fileFromFolder2.py
Upvotes: 1