[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Barry Warsaw barry at python.org
Fri Apr 12 17:02:54 CEST 2013
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Apr 12, 2013, at 03:31 PM, Dirkjan Ochtman wrote:
On Fri, Apr 12, 2013 at 2:55 PM, Eli Bendersky <eliben at gmail.com> wrote:
Ordered comparisons between enumeration values are not supported. Enums are not integers (but see
IntEnum
below)::>>> Colors.red < Colors.blue_ _Traceback (most recent call last):_ _..._ _NotImplementedError_ _>>> Colors.red <= Colors.blue_ _Traceback (most recent call last):_ _..._ _NotImplementedError_ _>>> Colors.blue > Colors.green Traceback (most recent call last): ... NotImplementedError >>> Colors.blue >= Colors.green Traceback (most recent call last): ... NotImplementedError I like much of this PEP, but the exception type for this case seems odd to me. Wouldn't a TypeError be more appropriate here? Somewhat like this:
'a' - 'b' Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for -: 'str' and 'str'
Interesting. I'm having a hard time articulating why, but NotImplementedError just feels more right to me in this case.
-Barry
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]