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/125556.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 26 00:23:55 CEST 2013
On 04/25/2013 03:07 PM, Barry Warsaw wrote:
> On Apr 25, 2013, at 02:30 PM, Ethan Furman wrote:
>
>> --> class Animal(Enum):
>> ...     ant = 1
>> ...     bee = 2
>> ...     fly = 3
>>
>> --> Animal(2)  # should return Animal.bee
>>
>> --> Animal('ant')  # should return Animal.ant
>>
>> It seems to me that storing the instances on the class as attributes is
>> mostly for convenience; we could just as easily not, and change the repr of
>> enumerators to '<Animal> ant [int=1]'.
>
> So I guess you would still expect these to hold true:
>
>      >>> Animal.ant is Animal(2)
>      True
>      >>> Animal.ant is Animal('ant')
>      True

Well, except for ant being 1, yeah.  ;)

--
~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