[Python-Dev] enum discussion: can someone please summarize open issues?
Stephen J. Turnbull
stephen at xemacs.org
Mon Apr 29 04:10:04 CEST 2013
Steven D'Aprano writes:
> >> - should an enum item be selectable via __call__ instead of __getitem__
> >> (i.e. Seasons(3) is AUTUMN)
> >
> > No opinion.
>
> Does anyone know why this is even an issue? Is this pure
> bike-shedding over the API, or are there technical reasons for
> choosing one over the other?
Ethan thinks that "Seasons(3)" is a typecast, not an access into a
mapping (which would be better expressed by "Seasons[3]"). Ie, the
inverse of "int(AUTUMN)".
This is consistent with the "AUTUMN is-a Seasons" position that Ethan
and Guido take. It's inconsistent with the "AUTUMN is-a
Seasons_VALUE" implementation of Flufl.Enum.
@Ethan: I have real trouble sympathizing with your point of view
because you consistently pluralize your Enum names. AUTUMN *is not* a
SeasonZZ, it is an element of the *collection* Seasons. OTOH, AUTUMN
*is* a Season (look Ma, no ZZ!) I wonder if you might not get more
sympathy from Guido if you named your Enums with the singular form.
Note that for some reason I don't have the same problem if Barry names
an Enum "Season" (no ZZ!) I don't know why, maybe because the
semantics of type is to define a collection (which in English is
invariably denoted by the plural of the type name), so there's
implicitly a plural there. But I'm not confident in that
psychoanalysis.
More information about the Python-Dev
mailing list