← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #219548]: Passing a Region as a arguement

 

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

j posted a new comment:
You don't need any keyword, because Python does not require typedefinitions like e.g. c# does. 
All you need is a name, and Python will determine its type when it is used at runtime. 
So "reg" and "value" are just variable names that could contain any kind of object. 

You could check if a variable has a certain type e.g. by using 
if (instance(reg, Region)):
    #do sth. with region
else:
    # do sth else

But normally you should know which type of variable you're going to get.

So if you write
def myTest(reg, value): 
the only thing "Python knows" it that there are two objects which can be anything. 
If you now use 
reg.exists(value)
Python will look up if the reg-object has a method with the name "exists" that takes one parameter, it doesn't care about the type of reg, only about the methods it has.

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