__builtins__.type() --- use instead: isinstance(some_object,class)

Asked by Lubos Kocman

What is the preferred way to get / compare types by using sikuli.

The standard type(obj) from python has been overriden by type(text) # That is not really smart

And __builtins__ seems to be unrecognized keyword.

I just wanted to check whatever passed argument is Region or Pattern. But generally missing __builtins__.type(object) is really a big con.
Thanks

Lubos

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

use instead:

isinstance(some_object,class)

which returns True or False.

e.g.

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

if isinstance(reg, Region):
   print "yes, a Region"

Can you help with this problem?

Provide an answer of your own, or ask Lubos Kocman for more information if necessary.

To post a message you must log in.