x = [1, 2, 3]
print(type(x))<class 'list'>
Mahamadi NIKIEMA
February 21, 2026
When using the function type on an object, Python will tell us which instance this object belongs to.
If we apply the type method to a class like list, we get:
A class is an instance of type and we can create a class from type.
type can take three arguments:
type(classname, superclasses, attributes_dict)
classname is the name of the classsuperclasses is a tuple of the superclassesattributes_dict is the dictionary attribute of the class.The same creation using type, passing an attribute a, and adding a method bark to the class:
<class '__main__.Dog'>
1
woof
We can access the attribute a and call the method bark, which was not possible during the first creation of the class.
Even if it is uncommon, we can use type to dynamically create classes. The class keyword is basically another way to create a class; under the hood, Python uses type.