I have two scripts in my current folder. From scriptMain.py
I call scriptChild.py
. In scriptMain.py
I have already imported numpy. However, it seems that even though I call scriptChild.py
by doing import scriptChild
it still needs me to import numpy in the child script again.
Is this default behaviour in python, or is there a way to tell the child script to recognise all modules imported by the parent script?
If it helps I am using python 3.5.1 and spyder as my editor.
edit1:
Suppose further that in scriptChild.py
I have that a=1
. I need the variable a
accessible through the parent as well. How do I make sure I do that. I tried running
import subprocess
subprocess.call("scriptChild.py", shell=True)
without any luck.
edit 2:
Found solution to edit 1 here: Importing a variable from one python script to another