4 ms·
OP: if you want bitmask-style enums, that's easy to code up with a derived class. The reference implementation shows how: https://bitbucket.org/stoneleaf/aenum/
by samps 13y ago
OP: if you want bitmask-style enums, that's easy to code up with a derived class. The reference implementation shows how: https://bitbucket.org/stoneleaf/aenum/src/0c66e1a5ec7b76388a3bab5403fdcf4729b9802c/aenum.py?at=default#cl-420 https://bitbucket.org/stoneleaf/aenum/src/0c66e1a5ec7b76388a...
- Tobu 13y agoLovely!
- d0mine 13y agoBelow is the excerpt from the module's docstring: On Wed, Feb 27, 2013 at 2:03 AM, Ethan Furman <ethan@stoneleaf.us> wrote: > I'm beginning to see why enums as a class has not yet been added to Python. > We don't want to complicate the language with too many choices, yet there is > no One Obvious Enum to fit the wide variety of use-cases: > > - named int enums (http status codes) > - named str enums (tkinter options) > - named bitmask enums (file-type options) > - named valueless enums (any random set of names) > - named valueless-yet-orderable enums (any not-so-random set of names That's probably the best succinct description of the core problem I've seen, and I've been following the various enum-related dicussions for years Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia