April 29, 2013
5:38 p.m.
On Mon, Apr 29, 2013 at 9:47 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
At this point I think the best course is to not allow duplicates directly in the enum definition, but allow them after the fact:
--> class Color(Enum): ... red = 1 ... green = 2 ... blue = 3
--> Color.grene = Color.green # stupid legacy typo
This gives us both some protection against accidental duplicates, while still allowing them when necessary; also, no confusion about which is the canonical name.
No. Poking a class has a code smell. It should be possible to define the aliases inside the enum class definition. The canonical one is the first one in definition order. -- --Guido van Rossum (python.org/~guido)