How to run multiple scripts at a time

Asked by Harry

Hi Raiman

1.I wanted to run 8 scripts at once.So i included "from sikuli import *" in all the 7 scripts and in last script i used "import (name of all the scripts separated by comma)" OR individually i imported seven scripts in the last one

2.I created one new script called as "main.sikuli" and in that i imported all 8 scripts one by one.

In both the cases i m getting "SyntaxError ( "mismatched input '-' expecting NEWLINE", )"
Please let me if i m doing something wrong.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

-- 1: running scripts using import …
is not a good idea.
imported scripts usually should not contain any code, that is run on import (indent level 0).
everything should at least be wrapped in def()s or even classes.

(one obvious reason: when using import in IDE one usually use
import sub
reload(sub)

to get chages done in parallel.

In your case, the code would be run twice.
)

so you normally have this:

import xyz
xyz.some_def()

or
from xyz import *
some_def()

but this is only a general comment ;-)

*** your problem
 "SyntaxError ( "mismatched input '-' expecting NEWLINE", )"
the reason is sometimes not obvious and might be caused by an error in the line before.
you get a line number and a position in the line, where the interpreter found a - , that does not make sense syntactically here.
e.g. hyphens are not allowed in names, only _

Revision history for this message
Harry (iam-harishetty) said :
#2

Raiman

That means we should not save the script with special characters

Still if i need to run script using import was my script correct i.e "import (all script name separated by comma OR one by one )"
I would run the last script which includes all

Revision history for this message
RaiMan (raimund-hocke) said :
#3

according to the latest Python "rules", using import x1, x2, x3, x4, … is allowed, but should not be used and each import should be on one line
import x1
import x2
import x3

or a gimmick ;-)
toImport = ("x1", "x2", "x3", "x4")
for m in toImport: exec("import %s"%(m))

Can you help with this problem?

Provide an answer of your own, or ask Harry for more information if necessary.

To post a message you must log in.