[Python-ideas] constant/enum type in stdlib (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jan 30 05:34:57 CET 2013
- Previous message: [Python-ideas] constant/enum type in stdlib
- Next message: [Python-ideas] constant/enum type in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-ideas] constant/enum type in stdlib
- Next message: [Python-ideas] constant/enum type in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]