[Python-ideas] PEP XXX - Competitor with PEP 435: Adding an enum type to the Python standard library

Nick Coghlan ncoghlan at gmail.com
Wed Mar 13 08:12:11 CET 2013

On Tue, Mar 12, 2013 at 4:42 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Ethan Furman wrote:
>> There seems to be two basic camps:  those that think an enum should be
>> valueless ... and those for whom the integer is an integral part of the
>> enumeration,
> I think most people agree that both of these use cases are
> important. The split seems to be more between those that
> want to address them using separate types, and those that
> prefer a one-type-fits-all approach.

There's a third camp - those that think the stdlib should just provide
a basic explicit "labelled value" building block, and let others worry
about composing them into more complex APIs and custom data types with
defined semantics.

Layered APIs are a good thing, and in this case, the obvious layering
option is to separate out the "labelling" part which is broadly useful
for debugging purposes from the "group of related values" part which
is used as a tool to help ensure program correctness by triggering
errors at the point of the undefined operation rather than allowing
nonsensical results based on an underlying data type like int or str.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list