sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #41223
Re: [Question #438963]: How to loop a master script (one that runs other scripts)
Question #438963 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/438963
Status: Open => Answered
RaiMan proposed the following answer:
Python import only runs the imported script at first time, to learn
about the names defined in the script. Import is usually used to make
variables, functions and classes available in other scripts (DRY
principle, reuse what already works).
So the most Python-like way would be to wrap the code in the scripts
into a def() :
--- script 1
def script():
# existing code indented one level
--- script 2
def script():
# existing code indented one level
--- main script
import script1
import script2
for n in range (3):
script1.script()
script2.script()
without any changes you can do this "ugly hack":
for n in range (3):
if n == 1:
import script1
import script2
continue
reload(script1)
reload(script2)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.