
June 16, 2021
2:27 p.m.
Great Idea, I have joined the mailing list to write the same idea. As I can't find the great difference between Final and Constant, So, I will use the name Final. I suggest one the following syntax: from collection import Final 》x = Final(100) 》print(x) 》100 》y = x*2 》Print(Y) 》200 》print (type(x)) 》< Final object.int at xxxxx> 》x=0 File "<stdin>", line 1 SyntaxError: can't assign to Final My understanding is Final will prevent x from reassigned. But if x is dict or list or string. it can be mutated in place. 》x = Final([1,2]) 》x.append(3) 》print(x) [1,2,3] If the programmer needs list that can't changed, he should move to other data structure like tuple. By using tuple & Final, the x will not accept reassigning nor mutation.