type()
Built-in FunctionPython 2.0+Beginner
Returns the type of an object, or creates a new type dynamically
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
print(type(42)) print(type("hello")) print(type([1, 2, 3])) print(type(True))
type() is a built-in function that returns the type of an object, or creates a new type dynamically.
Try in PlaygroundTags
builtinfunctioncoreoopintrospectionmetaclassdatatype
Related Items
isinstance()
Built-in Function
Returns True if an object is an instance of a given class or tuple of classes
issubclass()
Built-in Function
Returns True if a class is a subclass of another class
class
Keyword
Defines a new class (blueprint for creating objects)
object()
Built-in Function
Base class for all Python classes; returns a featureless object
__class__
Dunder Attribute
Reference to the class that an instance belongs to