← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #209132]: global variable across modules

 

Question #209132 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/209132

j posted a new comment:
You can also set a global var with the setattr() method.

You won't need to import something to your submodules and won't need to create an additional module. If the value of the EnableVerif value is not changeing during runtime, this will probably be the easiest way. 
It works like this:

for i in range(n):
    exec("import myModule%d"%(i))
    setattr("myModule%d"%(i), "EnableVerif", EnableVerif) 

This sets(adds) attribute "EnableVerif" with value "EnableVerif in
object "myModule%d"%(i). After this, you can access it like any other
var e.g. with myModule1.EnableVerif.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.