[EMAIL PROTECTED] wrote:
> Hi,
> 
> Is it possible to find out if an object is of a certain type or of a
> type derived from this type?

class Example(object):
   pass

class AnotherExample(Example):
   pass

>>> issubclass(Example, object)
True
>>> issubclass(AnotherExample, object)
True
>>> issubclass(AnotherExample, Example)
True
>>> issubclass(Example, AnotherExample)
False

And finally
>>> isinstance(Example, type)
True

This is true because type is the metaclass of object. Though you don't
have to understand it. ;)


Christian

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to