Reputation:
I have a main.py file and I need to import the database tables that are in "entity / models.py". How do I do ? I use linux and I don't want to add models.py to sys.path, I want models.py to be visible only in this project. I also don't want to create symbolic links because in my opinion it's the same thing as putting models.py inside the app itself.
Upvotes: 0
Views: 102
Reputation: 1872
You can convert the directory into a package with a __init__.py
file. Then as usual you can import the module from the package as in:
from entity.models import func
The __init__.py
file can just be an empty file. Just its existence will treat the directory as a package.
Hope this answer helps.
Upvotes: 1