[Python-ideas] constant/enum type in stdlib (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Jan 30 08:26:39 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 ]
On Wed, 30 Jan 2013 17:58:37 +1300 Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Guido van Rossum wrote:
> class color(enum): > RED = value() > WHITE = value() > BLUE = value() We could do somewhat better than that: class Color(Enum): RED, WHITE, BLUE = range(3) However, it's still slightly annoying that you have to specify how many values there are in the range() call. It would be even nicer it we could just use an infinite iterator, such as class Color(Enum): RED, WHITE, BLUE = values()
Well, how about:
class Color(Enum): values = ('RED', 'WHITE', 'BLUE')
?
(replace values with values if you prefer)
Regards
Antoine.
- 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 ]