I am practicing with Python using Pyramid framework.
I created a py, myfuncs.py, in my main package folder where there is also a Views folder with views.py inside and Models folder (models inside) along with other folders for static files and templates (as created by Pyramid scaffolding).
I want to define functions and classes within the myfuncs.py located at the myproject package root and then access them from within any of the views and models located in their respective views and models folder.
How can I achieve this? I try importing but it won’t work.
imagine this structures of folders and files:
Now you can “import” the folders (in reality you import __ init __.py using the folder name, but this is for now a detail)
Be sure to have the PYTHONPATH properly set.
for example:
etc.etc.
That __ init __.py must be in any folder you wish to import
Within views.py you simply do: