On 8/5/20 10:54 AM, David Mertz wrote:
I'm not advocating it, and I'm not the one that came up with it. But my impression is that it is intended to mean:
a = const('a', 5)
This doesn't seem completely pointless:
... def __init__(self, name, val): ... self.name = name ... self.val = val ... def about(self): ... print(self.name, '=', self.val) ...
a = const('a', 5) a.val
a = 5
There might be a way to subclass, e.g. int, so that you don't need to use `a.val` to get the value. It wasn't obvious to me how to do it in pure Python with 3 minutes thought.
--> from aenum import Constant
--> class K(Constant): ... a = 5 ...
--> K.a <K.a: 5>
--> K.a == 5 True
--> K.a - 3 2