I'm working on a translation (don't know if this is the correct term) of a code from MatLab to Python. While I can take advantage of the differences between the two languages it has been asked me to keep the file/folder structure the same, but right now I'm having some problems with the import of functions.
Every file is contained in one folder, that contains a file main.py
and a sub folder programs
.
In programs
I have a file called do_stuff.py
and another folder Data
.
In Data
I have one last file called DeviceData.py
.
The files are something like this:
DeviceData.py
:
def FuncDeviceData():
x=5
return x
do_stuff.py
:
def FuncDo_Stuff():
y=DeviceData()+1
print(y)
main.py
:
FuncDo_Stuff()
# TBN: code is oversimplified for clarity.
In the MatLab version there was a file used to add to the path all the subfolders but I honestly don't know how to do the same in python, or to do it "the python way".
I have tried the usual from file import func
but I cannot find a proper solution.
P.S. I don't usually work with python, I'm kinda doing this for fun and it could be useful for the overall project.