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…')
 
 
(One intermediate revision by one other user not shown)
Line 7: Line 7:
  
 
[[Category:Introduction to Programming]]
 
[[Category:Introduction to Programming]]
 +
[[Category:Python Functions]]
 +
[[Category:Computer programming]]

Latest revision as of 16:12, 18 May 2025

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