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:
class const():
... 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
5
a.about()
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
--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/DHVOCMK4OFX7KPX5J2ACJJXPI3UEVEBO/
Code of Conduct: http://python.org/psf/codeofconduct/