João Bernardo wrote:
And now for something completely different:
If the Enums are used with attribute syntax, why not this?
Enum.Colors.red.green.blue
Interesting idea, but there seem to be a couple of problems. It looks like you intend Enum to keep a record of all the enum types you create with it. What happens if two unrelated modules both define an enum called Colors? To avoid this problem, you'd want to assign the newly created enum type to a local name, but then you need to write the name twice: Colors = Enum.Colors.red.green.blue or Colors = Enum("Colors").red.green.blue Then what happens if you mistakenly write: print(Colors.pineapple) Seems like this would inadvertently add a new value to the enum instead of producing an AttributeError. -- Greg