Join our newsletter for the latest updates.

Python Program to Get the Class Name of an Instance

In this example, you will learn to get the class name of an instance.

To understand this example, you should have the knowledge of the following Python programming topics:


Example 1: Using __class__.__name__

class Vehicle:
    def name(self, name):
        return name

print(v.__class__.__name__)

Output

Vehicle

Example 1: Using type() and __name__ attribute

class Vehicle:
    def name(self, name):
        return name

v = Vehicle()
print(type(v).__name__)

Output

Vehicle

Using attribute __name__ with type(), you can get the class name of an instance/object.