how do you inherit globals from other .py file?
Example:
globals.py
test = 'testValue'
index.py
from globals import *
def setGlobals():
global test
test = 'new Value' # Setting new value to project global
setGlobals()
help.py
from globals import *
print test # Should print out 'new Value', but it prints 'testValue'
I wish to have one file full of constants and global variables that is set by another file and also used by other files. In this example I set new value to global variable test
in index.py
and wish to use new value in help.py
. Am I using the wrong approach for python? Thank you.
EDIT: Sequence of events is same as exampled, e.g. first I import, set new value and then try printing out newly set value from another file.