Consider the following code:
class Test:
def __init__(self):
self.historical = 5
t = Test()
# correct
print(t.historical)
# ops .. I made a mistake!
# an attribute error is thrown
#print(t.history)
# let's redefine the variable
# correct!
t.historical = 10
# ops ... I made a mistake!
t.history = 15 # <-- I want Python to throw an exception here
print(t.historical)
print(t.history)
In this code, I made a mistake: I assigned to history while the correct attribute name was historical.
How can I have Python throw an exception when I assign to history?
What is the best design decision to achieve this?