[Python-ideas] PEP for enum library type?
Jonathan Slenders
jonathan at slenders.be
Wed Feb 13 21:48:13 CET 2013
How is this a bug? It can be implemented in Python 3, I think. Only
Enum.__metaclass__ would not be able to know the order of it's
elements. (But unless you want to do bitwise operations, it's
irrelevant. Is alphabetical order okay?)
2013/2/13 Barry Warsaw <barry at python.org>
>
> On Feb 13, 2013, at 12:57 AM, Georg Brandl wrote:
>
> >class Color(Enum):
> > RED = 1
> > GREEN = ... # becomes 2
> > BLUE = ... # 3
> > MAGENTA = 5
> > FLUFL = ... # 6
>
> That's pretty cute.
>
> >class Color(FlagEnum):
> > RED = 1
> > GREEN = ... # becomes 2
> > BLUE = ... # 4
> > MAGENTA = 16
> > FLUFL = ...
> >
> >class Color(StringEnum):
> > RED = ... # becomes 'red'
> > GREEN = ... # etc.
> > BLUE = ...
>
> I want to think about the latter two (especially the string one), but I've
> filed this bug to track the feature.
>
> https://bugs.launchpad.net/flufl.enum/+bug/1124357
>
> Cheers,
> -Barry
More information about the Python-ideas
mailing list