I have a master script that executes several child scripts within subfolders of the main directory.
The folder hierarchy looks like:
MyFolder\MasterScript.py
MyFolder\ChildOneScript\ChildOne.py
MyFolder\ChildTwoScript\ChildTwo.py
MyFolder\ChildThreeScript\ChildThree.py
From MasterScript, I need call a function in ChildOne "myChildFunction" & pass some variables to it. The problem is, I cannot simply do
import ChildOneScript.ChildOne as ChildOne
ChildOne.myChildFunction
because there are other scripts that depend on the relative path of ChildOne. So if I import ChildOne to the MyFolder directory from the MasterScript and call myChildFunction there, I get traceback errors saying other files cannot be found. This is due to the mistakes of another stubborn programmer that refuses change his relative path calls, as it is a lot of manual work.
So, is there a way to call myChildFunction from within MasterScript and pass it some variables?
I'm aware I can use subprocess.call and it's cwd argument to change the working directory, but I can't figure out if it's possible to call the specific myChildFunction and pass it varaibles using subprocess.
Edit: Is it possible to pass variables using execfile?