← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #161632]: True or False when image is visible

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Since you are using return, I suppose we are talking about a function.

try this:

def myCheck(image):
    if exists(image): return True
    return False

try:/except: cannot be used, since exists() does not throw exceptions

same using find():

def myCheck(image):
    try: 
        find(image)
        return True
    except:
        return False

But why are you not using exists() directly? it returns a Match object if found and None if not. This can be used in any context where True/False are valid (if/elif/else, while).
So what is your intention/usage?

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