Вызывает исключение при обновлении атрибута 'constant' в python

Поскольку python не имеет понятия констант, можно ли вызвать исключение, есликонстанта» атрибут обновляется? Как?

class MyClass():
    CLASS_CONSTANT = 'This is a constant'
    var = 'This is a not a constant, can be updated'

#this should raise an exception    
MyClass.CLASS_CONSTANT = 'No, this cannot be updated, will raise an exception'

#this should not raise an exception    
MyClass.var = 'updating this is fine'

#this also should raise an exception    
MyClass().CLASS_CONSTANT = 'No, this cannot be updated, will raise an exception'

#this should not raise an exception    
MyClass().var = 'updating this is fine'

Любая попытка изменить CLASS_CONSTANT как атрибут класса или как атрибут экземпляра должна вызывать исключение.

Изменение var в качестве атрибута класса или атрибута экземпляра не должно вызывать исключение.

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

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