i have a similar problem but my global variable needs to be set in a function (f1 in my example) and recovered as is in a second one (f2). the value of the global is set by f0, witch is not editable. I have to send global n value with f0
in my test i did in a single file
class mytest():
def f1(value):
global n
n = value
print('test f1 : '+n)
def f2():
print('test f2 : '+n)
def f0():
mytest.f1("5")
mytest.f2()
f0()
result is 5 for f1 and f2, as expected. now i split in 2 files (to reproduce my need. no choice here, it must be splitted)
file1
def f0():
file2.mytest.f1("5")
file2
class mytest:
def f1(value):
global n
n = value
print('test f1 : '+n)
def f2():
print('test f2 : '+n)
f2()
error is : name 'n' is not defined
f1 is always run first by the app, then f2 is called I need f2 (and fX functions i need behind) to keep 'n' value from f1
thank you