sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #37322
Re: [Question #289066]: Variable values not carrying over to functions called from separate scripts
Question #289066 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/289066
Status: Open => Answered
RaiMan proposed the following answer:
global does not work across modules.
To make things more reliable, you should not use
from xxx import *
but
import xxx
and then use
xxx.someVariable
so it is always clear, in what module the requested name should be
found.
In your case, you need to import Test_Lib also in Test_Function and you
should always use functions, to set and get values, that are defined in
a module.
This is how I would do it:
# ... Test.sikuli:
import Test_Lib
import Test_Function
testvar1 = "TEST1"
print(testvar1)
print(Test_Lib.testvar2)
Test_Function.setTestvar1(testvar1) # to make the value available in the module Test_Function
Test_Function.printTest1()
Test_Function.printTest2()
# ... Test_Lib.sikuli:
testvar2 = "TEST2"
Test_Function.sikuli:
import Test_Lib
def setTestvar1(someValue):
global testvar1 # global within scope of Test_Function
testvar1 = someValue
def printTest1():
print(testvar1)
def printTest2():
print(testvar2)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.