On Apr 30, 2013, at 10:50 PM, Ethan Furman wrote: >The way I had subclassing working originally was for the subclass to create >it's own versions of the superclass' enum items -- they weren't the same >object, but they were equal: > >--> class Color(Enum): >... red = 1 >... green = 2 >... blue = 3 > >--> class MoreColor(Color): >... cyan = 4 >... magenta = 5 >... yellow = 6 > >--> Color.red is MoreColor.red >False > >--> Color.red == MoreColor.red >True > >If you switched from `is` to `==` would this work for you?
Not really, because in practice you don't compare one enum against another explicitly. You have a value in a variable and you're comparing against a literal enum. So `is` is still the more natural spelling. My point is, if you want enums to behave more class-like because you're using the class syntax, then you shouldn't explicitly break this one class-like behavior just to protect some users from themselves. There doesn't even seem to be an easy way to override the default behavior if you really wanted to do it. -Barry _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com