[Python-Dev] enum discussion: can someone please summarize open issues? (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Sat May 4 08:53:44 CEST 2013


Nick Coghlan wrote:

1. The current PEP, offering only "getattr(MyEnum, name)".

2. We restore getitem on EnumMetaclass solely for member lookup by name

  1. Use keyword arguments to distinguish two different ways of calling the enum class:

    MyEnum(value = 1) --> lookup by value MyEnum(name = "foo") --> lookup by name

MyEnum(1) could be made equivalent to MyEnum(value = 1) if it's thought that lookup by value will be the most common or natural case.

Pros: Explicit is better than implicit.

Cons: Not so convenient to get a type-conversion function to pass to other things.

-- Greg



More information about the Python-Dev mailing list