[Tutor] What would be good use cases for the enum module?
Steven D'Aprano
steve at pearwood.info
Mon Apr 10 23:50:49 EDT 2017
On Sun, Apr 09, 2017 at 10:21:49AM -0500, boB Stepp wrote:
> A general question about PEPs: Is there generally a PEP preceding the
> addition of any new feature to the core language or the standard
> library? I gather that even an accepted PEP (In this instance PEP
> 0435.) may not reflect the final form of the added feature(s) as I did
> not see direct mention of "auto", though that feature was alluded to.
It depends on the natural of the new feature. Generally only large,
complex or controversial changes require a PEP. Simple bug fixes or
small additions to existing functionality don't.
Once a feature/module has been added to the language, the PEP usually
stops being updated. So it effectively becomes a snapshot of what the
feature was intended to look like in Version X when it was first added,
not necessarily what it looks like in Version X+1.
> > Enums have a few other nice properties, which you may or may not care
> > about, but the primary use is to act as set of related named symbols.
> >
>
> The iterability looks useful. IntEnum looks interesting. IntFlag and
> Flag I am currently clueless about. I would have to dig deeper as I
> don't fully understand their uses yet.
Basically IntEnum and similar exist for compatability with C-style
enums, which are basically integers. That lets you combine flags with
bitwise OR. Sometimes that's useful, but its not the default for Python
enums.
--
Steve
More information about the Tutor
mailing list