I am currently making a module which exports the local variables to a python readable file and imports it through exec, but I am unable to modify them without using returns (Which is the whole idea). The problem boils down to:
I have two files, a module (module.py) and a main (main.py). I want the module to be able to execute code inside the main:
#module.py
def foo():
exec("b = a")
#main.py
from module import foo
a = 10
foo()
print(b)
Expected outcome
10
Actual outcome
NameError: name 'b' is not defined