I've a seemingly simple problem but can't find/figure out a solution.
I have two files and want to pass a variable from one script to the other, and update a variable in the calling script. I want to do this without modifying file_b:
file_a.py
inputs = {
"input_1": "value"
}
# Import/run file_b.py
print(outputs)
file_b.py
outputs = inputs.get("input_1")
I've tried this which is very close:
global inputs
inputs = {
"input_1": "value"
}
global outputs
outputs = []
exec(open("script_b.py").read(), globals())
print(outputs)
The exec method is able to send the variables to file_b but not get the outputs back.
Any help would be appreciated.