In the myfile.py file, we can import a function from the file.py file, like so
from functions.file import function1
One thing to note when importing a file from another directory in this way, is that you would need to include a file named __init__.py in the same directory of that file being imported. In the above example folder structure, we included __init__.py in the same directory as file.py. This lets Python know that a file is a package from which to import modules from.
What would be the correct way to import a file from a different directory, but not in a subfolder of the current file?
My boss is new to python and wants all the custom code in a different directory branch from the one that new scripts are developed and ‘launched’ from, for example (borrowing from your example):
The library here is a placeholder for any library or module you would want to import from (I think some used in the course include math and datetime). The * here indicates that you are importing all the variables and functions in that library or module.
However, note that using the * wildcard is not recommended.