Barry Warsaw wrote:
On Apr 13, 2013, at 12:51 PM, Steven D'Aprano wrote:
class Insect(Enum):
wasp = wsap = 1
bee = 2
ant = 3
What's the justification for this restriction? I have looked in the PEP, and
didn't see one.
If you allowed this, there would be no way to look up an enumeration item by
value. This is necessary for e.g. storing the value in a database.
Hm. What you really want there isn't two enum objects with
the same value, but two names bound to the same enum object.
Then looking it up by value would not be a problem.
--
Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com