I have a template directory where my test.py file is present.
Path to test.py dir is - /user/document/test1/template/test.py
(I have __init__.py
as well)
contest of test.py is
import os
test_dict = {
'number' : ['1', '2'],
'values' : ['a', 'b', 'c']
}
What I am trying in other script is
script.py
path to script.py is - /user/document/home/script.py
import os
os.chdir('/user/document/test1/')
exec('from template.test import test_dict')
print(test_dict)
And in the same dir I have another file called run.py
path to run.py is - /user/document/home/run.py
import subprocess
subprocess.Popen('python /user/document/home/script.py ',shell=True,stderr=subprocess.PIPE,stdout=subprocess.PIPE,universal_newlines=True)
Now when I run run.py (with pdb debugger) I see the exec from script.py
is not able to find the template module.
How do I make it right? I want test_dict
from test.py inside script.py