[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
Dirkjan Ochtman
dirkjan at ochtman.nl
Fri Apr 12 15:31:12 CEST 2013
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 "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'str'
Cheers,
Dirkjan
More information about the Python-Dev
mailing list