Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


I guess this is new to Py 3k? Thanks for the tip!


Right, 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/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: