I am trying to access a variable from a python module which is being run as a script. The variable is defined in the if __name__ == "__main__"
:
The code I am working with looks something like this:
MyCode.py
cmd = 'python OtherCode.py'
os.system(cmd) # Run the other module as a python script
OtherCode.py
if __name__ == "__main__":
var = 'This is the variable I want to access'
I was wondering if there was a way to access this variable while still running the OtherCode.py as a script.