Isinstance function

Revision as of 22:11, 5 May 2011 by Smitschu (talk | contribs) (Created page with 'The '''isinstance function''' in Python checks whether or not a given object is an instance of a given class. This is sometimes useful because P…')
(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