← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #225600]: match a list with another no matter of the order

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
To make it clear:
- you have the images 1 ... 30
- you evaluate a combination of 2 images out of these 30 (e.g. (1, 3) or (5,9) or (28, 30) ...)
- now you want to do an action only for a specific set of these couples

So you first have to define the different sets of couples you are interested in (the numbers have to be replaced by valid image names:
set1 = ( (1,2), (2,5), (10,15), (29,15) )
set2 = ( some other couples )
set3 = ....

Now you need a function, that returns True, if a given couple is
contained in a given set:

def setContains(aset, acouple):
    for c in aset:
        if c[0] == acouple[0] and c[1] == acouple[1]:
            return True
    return False

which you now can use for your decisions:
if setContains(set1, a_given_couple): print "Action1"
if setContains(set2, a_given_couple): print "Action2"
# .....

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