4 ms·
It's possible by using a __prepare__ method in the metaclass of Enum, which allows to return an essentially ordered dict for the __dict__ of enumeration classes
by eliben 13y ago
It's possible by using a __prepare__ method in the metaclass of Enum, which allows to return an essentially ordered dict for the __dict__ of enumeration classes.
- marmaduke 13y agoI guess this is new to Py 3k? Thanks for the tip!
- paul_odin 13y agoRight, PEP 3115. Indeed one of the reasons is that "there is an important body of use cases where it would be useful to preserve the order in which a class members are declared." http://www.python.org/dev/peps/pep-3115/ http://www.python.org/dev/peps/pep-3115/