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/125747.html below:

[Python-Dev] Enumeration items: mixed types?

[Python-Dev] Enumeration items: mixed types? [Python-Dev] Enumeration items: mixed types?Ethan Furman ethan at stoneleaf.us
Tue Apr 30 01:16:48 CEST 2013
On 04/29/2013 03:50 PM, Ethan Furman wrote:
> This just doesn't make sense to me:
>
> --> class Stuff(Enum):
> ...     blue = 1
> ...     china = 'really big country'
> ...     random = (8273.199, 517)
>
> --> Stuff.blue.name == 'blue'
> --> Stuff.blue.value == 1
>
> --> Stuff.china.name == 'china'
> --> Stuff.china.value == ???
>
> --> Stuff.random.name == 'random'
> --> Stuff.china.value == ???
>
> In order to make this work at all, we have to support auto-numbering, and I didn't think we were going to do that in the
> class syntax?

I suppose the other option is to have `.value` be whatever was assigned (1, 'really big country', and (8273.199, 517) ), 
and the fact that `int(Stuff.china) ` blows up and doesn't store easily in a database is the programmers issue...

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