__class__

Dunder AttributePython 2.0+Intermediate

Reference to the class that an instance belongs to

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# __class__ refers to an object's type
x = 42
print(x.__class__)
print(x.__class__.__name__)

class Dog:
    pass

d = Dog()
print(d.__class__)

__class__ is a special attribute that reference to the class that an instance belongs to.

Try in Playground

Tags

oopintrospectioncore