Hey guys, in this blog we will see a Python Program to Get the Class Name of an Instance.
Example 1: Using __class__.__name__
class Project:
def name(self, name):
return name
p = Project()
print(p.__class__.__name__)
Output
Project
- We can use object.__class__.__name__ to get the class name of the object.
Example 2: Using type() and __name__ attribute
class Project:
def name(self, name):
return name
p = Project()
print(type(p).__name__)
Output
Project
- We can also use type(object).__name__ to get the class name of the object.
Check out our other python programming examples…


![[Latest] Python for Loops with Examples – Easiest Tutorial – 2025](https://machinelearningprojects.net/wp-content/uploads/2023/05/python-for-loops-1-1024x536.webp)


