Difference between revisions of "Isinstance function"

(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…')
 
m
 
Line 7: Line 7:
  
 
[[Category:Introduction to Programming]]
 
[[Category:Introduction to Programming]]
 +
[[Category:Python Functions]]

Latest revision as of 17:53, 2 September 2011

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