There is a several-month-old request to add aenum's [1] AutoNumberEnum to the stdlib [2]. The requester and two of the three developers of Enum are in favor (the third hasn't chimed in yet). This new addition would enable the following: from Enum import AutoNumberEnum class Color(AutoNumberEnum): # auto-number magic is on Red Green Blue Cyan # magic turns off when non-enum is defined def is_primary(self): # typos in methods, etc, will raise return self in (self.Red, self.Grene, self.Blue) # typos after the initial definition stanza will raise BlueGreen = Blue + Grene There is, of course, the risk of typos during the initial member definition stanza, but since this magic only happens when the user explicitly asks for it (AutoNumberEnum), I think it is acceptable. The `start` parameter is still available, and assigning a number is supported (subsequent numbers will (re)start from the assigned number). Thoughts? Opinions? Flames? -- ~Ethan~ [1] https://pypi.python.org/pypi/aenum [2] http://bugs.python.org/issue26988
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4