May 4, 2013
6:53 a.m.
Nick Coghlan wrote:
1. The current PEP, offering only "getattr(MyEnum, name)".
2. We restore __getitem__ on EnumMetaclass *solely* for member lookup by name
3. 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