[Python-Dev] enum discussion: can someone please summarize open issues?

Guido van Rossum guido at python.org
Fri May 3 16:46:04 CEST 2013


On Fri, May 3, 2013 at 7:14 AM, Eli Bendersky <eliben at gmail.com> wrote:
> I'm just curious what it is about enums that sets everyone on a "let's make
> things safer" path. Python is about duck typing, it's absolutely "unsafe" in
> the static typing sense, in the most fundamental ways imaginable. When
> programmatically invoking a method on a class (say some sort of RPC), we
> don't check that the class is of the correct type. We invoke a method, and
> if it quacks, that's a good enough duck. If it was actually the wrong class,
> something will break later. EAFP Is a central Python tenet, whether we like
> it or not. If one looks for static guarantees, Python surely shouldn't be
> the preferred language, no?
>
> And concretely, how is this case different from any programmatic attribute
> access in Python objects? You can pass dunders to getattr() and it probably
> wasn't what you meant, but Python does not do this type checking for you.
> Why is an Enum different than any other class?

Let's make that a topic for a separate, more philosophical thread, python-ideas.

Back to this particular issue, I haven't seen code in the style that
Greg proposes in decades, and I don't think it is an important enough
use case to support more directly than through getattr() +
isinstance().

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list