Search code examples
pythonjythonsikulibuilt-in

How to check variable type using “type” function in Sikuli


Sikuli has its own function type for typing. Is there any way to invoke python (jython) function type? Module builtins can’t be imported. Of course I can use isinstance instead but I am just curious if it is possible to come outside Sikuli scope and invoke not “overridden”, python built-in type function. I use Sikuli r930.

#import builtins                         #ImportError: No module named builtins
findAll("1369036502514.png")
matches = getLastMatches()
print(isinstance(matches,Finder))        #returns TRUE
type("1369035684637.png",'hello world')  #types characters 
type('hello world again')                #types characters 
print(type(matches))                     #TypeError: type(): 1st arg can't be coerced to String

Running builtins.type results in failure too:

builtins.type(matches)
NameError: name 'builtins' is not defined

__builtins__.type(matches)
NameError: name '__builtins__' is not defined

Solution

  • You can use matches.__class__.