← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #162999]: Using dictionaries

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- the dictionary

myDict = {}
myDict["image1"] = "2123904.png"
mydict["image2"] = "2318371.png"
myDict["image3"] = "7390302.png"

the keys of the dictionary have to be known objects. In this case, it
makes sense, to use strings.

--- the "import" problem

import os
sikuliPath = r"c:\\sikuli\\imageshiRes.sikuli"
fullPath = r"c:\\sikuli\\imageDictWrapper.sikuli\\imageDictWrapper.py"
execfile(fullPath)
setBundlePath(sikuliPath)

since you are using execfile(), the definitions contained in
imageDictWrapper.py are already "imported".

I would prefer to use imports instead of your sequence

sikuliPath = r"c:\sikuli" # with raw strings ( r" " ) only one backslash is needed
if not sikuliPath in sys.path: sys.path.append(sikuliPath)
import imageshiRes
import imageDictWrapper

image files in both .sikuli will be found.

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