__dict__

Dunder AttributePython 2.0+Intermediate

Dictionary holding an object's writable attributes

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# __dict__ holds an object's attributes
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

p = Person("Alice", 30)
print(p.__dict__)
print(Person.__dict__.keys())

__dict__ is a special attribute that dictionary holding an object's writable attributes.

Try in Playground

Tags

oopintrospectioncore