Isinstance function

Revision as of 16:53, 2 September 2011 by Smitschu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The isinstance function in Python checks whether or not a given object is an instance of a given class. This is sometimes useful because Python is dynamically typed, so the class of object stored in a variable may not be known until runtime. It has the following syntax:

isinstance(object, Class)

It will return True if object is an instance of Class or a subclass of Class, and False otherwise.

See Also

Python 3.2 Documentation