Classes Are Instances of type

python
TIL
Understanding Python’s type and Class Creation
Author

Mahamadi NIKIEMA

Published

February 21, 2026

When using the function type on an object, Python will tell us which instance this object belongs to.

x = [1, 2, 3]
print(type(x))
<class 'list'>

If we apply the type method to a class like list, we get:

print(type(list))
print(type(type(x)))
<class 'type'>
<class 'type'>

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)

class Dog:
    pass

dog = Dog()
print(type(dog))
<class '__main__.Dog'>

The same creation using type, passing an attribute a, and adding a method bark to the class:

Dog = type("Dog", (), {"a":1, "bark": lambda self: "woof"})
d = Dog()
print(type(d))
print(d.a)
print(d.bark())
<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.