Thuộc tính __dict__ trả về dictionary từ các trường của bất kỳ đối tượng nào.
Định nghĩa class person:
>>> class person:
... def __init__(self):
... self.name = 'foo'
... self.age = 20
... def show(self):
... print(self.name, self.age)
Khai báo đối tượng của class này và lấy thuộc tính __dict__:
>>> p = person()
>>> d = p.__dict__
>>> d
{'name': 'foo', 'age': 20}