This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients alex, eric.smith, ethan.furman, ncoghlan
Date 2013-05-12.12:44:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hmm, that's an interesting point about allowing operations on the already defined values.

You could get around that by requiring that the wrapper be explicit when definined the alias:

>>> class Shape(enum.Enum):
...   rectangle = 1
...   oblong = enum.alias(rectangle)

Or, equivalently:

>>> class Shape(enum.Enum):
...   rectangle = 1
...   oblong = enum.alias(1)

So simple typos would trigger an error by default, and the enum.alias wrapper would tell the namespace (or the metaclass) "hey, this should be an alias for another value already defined here".

I definitely don't want us to turn the metaclass into a swiss army knife of behavioural options - I'm happy with customisation hooks in the metaclass on that front, as I believe it is an effective way to discourage excessive use of metaclass magic without preventing it when it is necessary.
Date User Action Args
2013-05-12 12:44:41ncoghlansetrecipients: + ncoghlan, eric.smith, alex, ethan.furman
2013-05-12 12:44:41ncoghlansetmessageid: <>
2013-05-12 12:44:41ncoghlanlinkissue17959 messages
2013-05-12 12:44:41ncoghlancreate