Почему ты не можешь добавить атрибуты к объекту в python? [Дубликат]

На этот вопрос уже есть ответ:

Не могу установить атрибуты класса объекта 6 ответов

(Написано в оболочке Python)

>>> o = object()
>>> o.test = 1

Traceback (most recent call last):
  File "<pyshell#45>", line 1, in <module>
    o.test = 1
AttributeError: 'object' object has no attribute 'test'
>>> class test1:
    pass

>>> t = test1()
>>> t.test

Traceback (most recent call last):
  File "<pyshell#50>", line 1, in <module>
    t.test
AttributeError: test1 instance has no attribute 'test'
>>> t.test = 1
>>> t.test
1
>>> class test2(object):
    pass

>>> t = test2()
>>> t.test = 1
>>> t.test
1
>>> 

Почему объект не позволяет добавлять атрибуты к нему?

Ответы на вопрос(2)

Ваш ответ на вопрос