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/126062.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? YesEthan Furman ethan at stoneleaf.us
Tue May 7 04:29:32 CEST 2013
On 05/05/2013 02:55 PM, Tim Delaney wrote:
>
> So long as I can get one of the requirements documented to implement an auto-number syntax I'll be happy enough with
> stdlib enums I think.
>
> class Color(AutoIntEnum):
>      red = ...
>      green = ...
>      blue = ...
>

Will this do?

     class AutoNumber(Enum):
         def __new__(cls):
             value = len(cls.__enum_info__) + 1
             obj = object.__new__(cls)
             obj._value = value
             return obj
         def __int__(self):
             return self._value
     class Color(AutoNumber):
         red = ()
         green = ()
         blue = ()

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