Author ethan.furman
Recipients barry, eli.bendersky, eric.snow, ethan.furman, ncoghlan, pitrou, r.david.murray
Date 2013-09-13.15:31:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1379086272.5.0.0699030483171.issue18989@psf.upfronthosting.co.za>
In-reply-to
Content
In any other (normal) class, this works:
==================================================================================
-->class Okay:
...   red = 1
...   green = 2
...   blue = 3
...   red = 4
==================================================================================

But not in Enum.

And this works:
==================================================================================
-->class Color:
...   red = 1
...   green = 2
...   blue = 3
...   def red(self):
...     return 42
... 
--> Color.red
<property object at 0x7fee4db306d8>
==================================================================================

This only works in Enum because we added code to deal with it.  If we hadn't, we'd see this:
==================================================================================
<Color.red: <property object at 0x7fee4db30f58>>
==================================================================================

So right now the rule is:  you can overwrite an enum member with anything besides another enum member.  Considering the point of the Enum class is to create enum members this rule is nonsensical as it allows the removal of already created members.

At the very least the rule should be: enum members cannot be overwritten.

I prefer to have the rule: enum members cannot overwrite anything else, and cannot be overwritten by anything else.  This seems to me to be a simpler, more consistent rule, and more in keeping with what an enumeration should be doing.
History
Date User Action Args
2013-09-13 15:31:12ethan.furmansetrecipients: + ethan.furman, barry, ncoghlan, pitrou, r.david.murray, eli.bendersky, eric.snow
2013-09-13 15:31:12ethan.furmansetmessageid: <1379086272.5.0.0699030483171.issue18989@psf.upfronthosting.co.za>
2013-09-13 15:31:12ethan.furmanlinkissue18989 messages
2013-09-13 15:31:12ethan.furmancreate