

Why don’t people use enum in Python? - cool-RR
http://blog.garlicsim.org/post/6388800336/why-dont-people-use-enum-in-python

======
sc68cal
Declaring that you've never programmed in Java, then cherry-picking a type
from the language and asking why Python doesn't have it, is quite ironic,
given the vast differences in typing between the two languages.

~~~
cool-RR
I really don't understand your point. I'm happy to learn things from Java and
apply them in Python despite the fact that I never programmed Java.

Regarding the differences in typing between Java and Python: Despite of these
differences, `flufl.enum` _does_ work in Python, so I don't see how these
differences are relevant.

~~~
sc68cal
flufl.enum attempts to _reject PEP 354, ... [and] defines an alternative
syntax and semantics._

PEP 354 was a proposal to add enums to the language, stating:

 _The properties of an enumeration are useful for defining an immutable,
related set of constant values that have a defined sequence but no inherent
semantic meaning._

I'm sure someone raised this question while the PEP was being debated: If you
are looking for an immutable, related set of (though not immutable or
constant) values, you should look no further than the list object.

In fact, most of the PEP could be run through a find and replace, with enum
being replaced by lists, or sets, or other types that have attributes from the
Sequence abstract base class.

But anyway, that's just a few Python specific things I could think off the top
of my head.

My central argument revolves around the differences between Java and Python,
and how I've seen enums used. The Java programming language is statically
typed, and it is useful to have a basic type that can contain a value, from a
set of immutable values. It helps catch any obvious errors, at compile time.
For example, using a value which is not part of the enum definition.

Python, being a dynamic language, doesn't have the notion of a compile-time
type check.

>I'm happy to learn things from Java and apply them in Python despite the fact
that I never programmed Java.

Well, that's a statement that is sure to cause a few eyebrows to be raised.

