Nick Coghlan added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17959>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to