
Jan. 29, 2013
10:34 p.m.
Guido van Rossum wrote:
this doesn't look so bad, and certainly doesn't violate DRY (though it's somewhat verbose):
class color(enum): RED = value() WHITE = value() BLUE = value()
The verbosity is what makes it fail the "truly elegant" test for me. And I would say that it does violate DRY in the sense that you have to write value() repeatedly for no good reason. Sure, it's not bad enough to make it unusable, but like all the other solutions, it leaves me feeling vaguely annoyed that there isn't a better way. And it *is* bad enough to make writing an enum definition into a dreary chore, rather than the pleasure it should be. -- Greg