Zgłaszanie wyjątku dotyczącego aktualizacji atrybutu „stała” w pythonie

Jak python nie ma pojęcia stałych, czy byłoby możliwe zgłoszenie wyjątku, jeśli atrybut „stały” został zaktualizowany? W jaki sposób?

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'

Każda próba zmiany CLASS_CONSTANT jako atrybutu klasy lub jako atrybutu instancji powinna wywołać wyjątek.

Zmiana var jako atrybutu klasy lub jako atrybut instancji nie powinna powodować wyjątku.

questionAnswers(5)

yourAnswerToTheQuestion