← Back to team overview

sikuli-driver team mailing list archive

[Question #269004]: isinstance(Region) vs. isinstance(Region.nearby) not giving the same result

 

New question #269004 on Sikuli:
https://answers.launchpad.net/sikuli/+question/269004

Hello,

Tried to search for an answer but did not find anything satisfactory but I'm kinda bad at Internet search (so sorry if an answer already exists)

Here is my problem:
I'm trying to write some function that performs specific processing based on parameter type (mainly Match or Region).
No problem with Match, but Region seems a bit more tricky so I dug a bit more and found out that there seems to have several types of Region, depending where it comes from.

This code (with Sikuli 1.0.1):
  from sikuli import *

  reg = Region(1,1,100,100)

  print "Is reg a Region?"
  if isinstance(reg, Region):print "yes, a Region"
  else:print "nope, not a Region"

  print "Is reg.nearby(5) a Region?"
  if isinstance(reg.nearby(5), Region):print "yes, a Region"
  else:print "nope, not a Region"

gives

  Is reg a Region?
  yes, a Region
  Is reg.nearby(5) a Region?
  nope, not a Region


Seeing this result (which seems strange as documentation says that nearby() "Returns a new Region"), I tried this
  print "reg class=%s"%reg.__class__
  print "reg.nearby(5) class=%s"%reg.nearby(5).__class__
and got
  reg class=<class 'sikuli.Region.Region'>
  reg.nearby(5) class=<type 'org.sikuli.script.Region'>


So, here comes the question: what am I doing wrong to get reg.nearby(5) not being a Region?


Thanks in advance
Romuald

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