0

I would like to know if it's possible to check if a variable is this type:

<type 'gtk.gdk.PixbufLoader'>

with a line like:

if type(var) == 'gtk.gdk.PixbufLoader':  # pseudocode
   print "Found!"

Thanks

1
  • It is with noting that checking the type of variables in python is often a sign of a design issue, as Pythonic code shouldn't usually require it. Sometimes it is unavoidable, but if you start doing it a lot, you should rethink your design. Python is a duck typed language - what type it is isn't meant to be important. Commented Jan 12, 2015 at 17:02

1 Answer 1

5

You can use isinstance:

if isinstance(var, gtk.gdk.PixbufLoader):
    print 'Found!'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.