[Python-Dev] enum discussion: can someone please summarize open issues?
Ethan Furman
ethan at stoneleaf.us
Mon Apr 29 18:47:43 CEST 2013
On 04/29/2013 09:30 AM, Larry Hastings wrote:
>
> On 04/29/2013 06:51 AM, Eli Bendersky wrote:
>> flufl.enum disallows this:
>>
>> class Color(Enum):
>> red = 1
>> blue = 2
>> green = 1 # oops!
>>
>> Has it been decided that this is now allowed? If this is indeed the case, then Color(1) is a problem. The options are:
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.
Guido?
--
~Ethan~
More information about the Python-Dev
mailing list