> You may not define two enumeration values with the same integer value::
>
>     >>> class Bad(Enum):
>     ...     cartman = 1
>     ...     stan = 2
>     ...     kyle = 3
>     ...     kenny = 3 # Oops!
>     ...     butters = 4
>     Traceback (most recent call last):
>     ...
>     ValueError: Conflicting enums with value '3': 'kenny' and 'kyle'
>
> You also may not duplicate values in derived enumerations::
>
>     >>> class BadColors(Colors):
>     ...     yellow = 4
>     ...     chartreuse = 2 # Oops!
>     Traceback (most recent call last):
>     ...
>     ValueError: Conflicting enums with value '2': 'green' and 'chartreuse'
>

Is there a convenient way to change this behavior, namely to indicate that
conflicts are acceptable in a given Enum? While I like the idea of catching
mistaken collisions, I've seen far too many C/C++ scenarios where multiple
names map to the same value. This does raise questions, as it's unclear
whether each name should get its own representation, or whether it's better
to let DupEnum.name1 is DupEnum.name2 be True.

(For the latter behavior, would adding DupEnum.name2 = DupEnum.name1 after
the class declaration work today?)

Michael
-- 
Michael Urman
_______________________________________________
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

Reply via email to