On 8/5/20 11:11 AM, Jonathan Goble wrote:
That's literally useless, because after running that there is nothing stopping you from doing:
a = 10
or even:
a = "python has no constants"
And now a has a value different from 5.
There is nothing even remotely resembling const-ness to that class. In order to get const-ness, you would need the ability to overload assignments, like C++ can do. And Python can't do that, and that's probably a good thing.
--> from aenum import Constant
--> class K(Constant):
... a = 5
... b = 'hello'
...
--> K.a