A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-April/125302.html below:

[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard libraryEthan Furman ethan at stoneleaf.us
Fri Apr 12 21:58:22 CEST 2013
On 04/12/2013 12:37 PM, � wrote:
> On Fri, Apr 12, 2013 at 7:21 PM, Russell E. Owen <rowen at uw.edu> wrote:
>> Using intEnum is certainly doable, but that opens up the door to
>> comparing values from different Enums, which is not something I'd want
>> to allow.
>
> I agree. Comparing values from different Enums could cause a lot of
> hard to find bugs.
>
> On the other hand, simply checking in `__cmp__` what Enum both values
> belong to (since they do have a `enum` attribute) should allow us to
> avoid cross-comparing instead of just raising a TypeError. It's not
> very intuitive behavior IMHO.

Something like this is what happens for Enums, but IntEnums are subtypes of int, and if we had something like:

class Fruit(IntEnum):
   apples = 1
   bananas = 2
   oranges = 3

class Flowers(IntEnum):
   roses = 1
   lillies = 2
   violets = 3

--> Fruit.apples == 1
True

--> Flowers.roses == 1
True

--> Fruit.apples == 1 == Flowers.roses
???

This way lies madness.

--
~Ethan~
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4