Well, I’ve ended my own implementation of enum. This does not make me proud neither is something I like, particularly because it’s huge for something that I think should be more simple or part of the language. One hint for this is the many enum-like solutions you can find around the net. Some are simple and clean, but none provides all the features I need.
Anyhow, the module is pretty cool and does everything I ever wanted. From the first part:
- An easy way to declare a type with a set of related constants: a name and an (integer) value
- An easy way to convert a constant from its value to its name, and vice-versa.
- An easy way to declare sequence-based constants and bit-based flag constants.
- The type must not be immutable: new constants may be added later.
Continue reading ‘The quest for the perfect python enum/constant declaration, Part 2′
Recent Comments