[Python-Dev] enum discussion: can someone please summarize open issues?

Eli Bendersky eliben at gmail.com
Mon Apr 29 14:24:59 CEST 2013


On Sun, Apr 28, 2013 at 12:32 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

> Example enumeration:
>
> class Seasons(Enum):
>     SPRING = 1
>     SUMMER = 2
>     AUTUMN = 3
>     WINTER = 4
>
>     days_in_year = 365
>
>     @property
>     def avg_temp(self):
>         return (75, 92, 66, 33)[int(self)+1] # enums are 1-based
>
>
> Definite Issues:
>
>   - should enum items be of the type of the Enum class? (i.e. type(SPRING)
> is Seasons)
>
>   - should an enum item be selectable via __call__ instead of __getitem__
> (i.e. Seasons(3) is AUTUMN)
>
>   - should days_in_year be enumerated?
>
>   - should avg_temp be enumerated?
>
>   - for the above two, how should they be included/excluded?
>

Thanks for the summary. One issue I don't see addressed here is
int-compatibility. Am I correct to assume that nothing changes w.r.t. that,
and that an IntEnum subclass of Enum will be provided which is
isinstance(integer)? Does that become straightforward by nature of enum
values being the type of their enumerations?

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130429/5cfd7171/attachment.html>


More information about the Python-Dev mailing list