Type function
Python’s type() function returns an object’s type when called with one argument and can create a class when called with class-construction arguments.
The Quick Python Book, Fourth Edition
The Python type function returns an object's type or creates a new type when called with class-construction arguments.
- How it is used
- Uses type to inspect objects, identify classes, and support runtime type checks.
- How deep it goes
- Explains returned type objects, instance inspection, inheritance metadata, and validation use, but does not develop class construction through type.
- Examples
- Demonstrates integers, lists, user-defined instances, inheritance, and a TypedList that enforces homogeneous elements.
- What you can do after
- Diagnose object and class relationships, then apply captured types in runtime validation.
Read how The Quick Python Book, Fourth Edition explains type function →
Python How-To
type is a Python built-in function that returns the type of an object.
- How it is used
- Uses runtime type inspection to make functions accept and process different input forms.
- How deep it goes
- Explains the return value and a worked type-based branch, while deferring superclass-friendly checks to isinstance.
- Examples
- Demonstrates integers, lists, reassigned variables, assertions, and a task-filtering function.
- What you can do after
- Apply it via Python’s built-in type function to inspect values and branch behavior for supported input types.
Get Programming: Learn to code with Python
A Python built-in function that returns the type of an object.
- How it is used
- Checks an object's data type in the Python console when its type is uncertain.
- How deep it goes
- Defines type() and demonstrates console checks, but does not explain its internal implementation.
- Examples
- Uses type(3) and type("wicked") to identify integer and string values.
- What you can do after
- Evaluate values in the console to identify their data types.
Read how Get Programming: Learn to code with Python explains type function →
Related concepts
- atomic typemeasures · An atomic type is a type whose supported accesses and operations are indivisible with respect to concurrent execution and provide defined synchronization semantics.
- __class__ attributeequivalent to · The __class__ attribute references the class object associated with a Python object.
- reflectionused by · Reflection is a programming capability for inspecting or interacting with program types, members, values, or metadata dynamically at runtime.
- isinstancecontrasts with · isinstance is a Python built-in function that tests whether an object is an instance of a specified class or tuple of classes, including subclasses.
- objectuses · A computational object is a runtime entity or structured value representing data, state, or a resource, with properties or operations defined by its programming model.
- classproduces · A class is a programming-language construct that defines a type’s structure or behavior and provides a basis for creating or representing objects.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


