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

[Python-Dev] PEP 435: initial values must be specified? Yes

[Python-Dev] PEP 435: initial values must be specified? Yes [Python-Dev] PEP 435: initial values must be specified? YesGreg Ewing greg.ewing at canterbury.ac.nz
Mon May 6 01:57:13 CEST 2013
Ethan Furman wrote:
> --> class Color(Enum):
> ...     red, green, blue
> ...
> 
> --> class MoreColor(Color):
> ...     red, orange, yellow
> ...
> 
> --> type(MoreColor.red) is MoreColor
> False

This argument no longer applies, since we're not
allowing enums to be extended.

> class Color(Enum):
>     red = e()
>     green = e()
>     blue = e()
> 
> and you can keep using `e()` for all your enumerations, since you don't 
> care what actual value each enumeration member happens to get.

I don't think it's true that people wanting auto-numbering
don't care what values they get. Rather, they probably want
ordinal values assigned separately and consecutively for
each type, as in every other language I'm aware of that
provides auto-numbered enums.

If you *really* don't care what the values are, there's no
need for the items to have values at all.

-- 
Greg

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