[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Apr 25 02:33:07 CEST 2013


R. David Murray wrote:

If 'a' is now an instance of MyEnum, then I would expect that:

MyEnum.a.b would be valid

That is indeed a quirk, but it's not unprecedented. Exactly the same thing happens in Java. This compiles and runs:

enum Foo { a, b }

public class Main {

 public static void main(String[] args) {
   System.out.printf("%s\n", Foo.a.b);
 }

}

There probably isn't much use for that behaviour, but on the other hand, it's probably not worth going out of our way to prevent it.

-- Greg



More information about the Python-Dev mailing list