Should nested classes in an Enum be Enum members?
Ben Finney
ben+python at benfinney.id.au
Fri Jun 29 00:03:41 EDT 2018
Ethan Furman <ethan at stoneleaf.us> writes:
> On 06/28/2018 05:58 PM, Ben Finney wrote:
>
> > So I remain dumbfounded as to why anyone would want a class to *both* be
> > an enumerated type, *and* have callable attributes in its API.
>
> Perhaps I am using Enum incorrectly, but here is my FederalHoliday
> Enum. […]
Thanks for the example. Yes, my personal impression is that class
is not a good use of enum.Enum (nor enum.AutoEnum).
To inherit from enum.Enum (or enum.AutoEnum) signals, to my mind, that
the class is not really intended as a typical Python class, but instead
is intended to be that special beast known as an “enumerated type” which
has little behaviour other than being a namespace for constant values.
Adding all that other stuff just makes it quite unclear what the class
means any more.
--
\ “Pinky, are you pondering what I'm pondering?” “I think so, |
`\ Brain, but me and Pippi Longstocking — I mean, what would the |
_o__) children look like?” —_Pinky and The Brain_ |
Ben Finney
More information about the Python-list
mailing list