Message274876
> Any problems with:
>
> class Color(Enum): # or Color(Flag)
> red = _auto_
> green = _auto_
> blue = _auto_
As long as _auto_ has been defined somewhere (i.e. from enum import _auto_), it is normal Python and doesn't fight with the rest of language or its toolchains.
The idea does seem to be at odds with the enum module itself. Heretofore, the rule for the module is that if the same object is assigned to multiple variable names, those names become synonyms.
>>> from enum import Enum
>>> class Color(Enum):
red = 1
magenta = 1
orange = 2
ochre = 2
>>> Color.orange is Color.ochre
True
Also, I still question the need, you already have multiple ways to do it:
Color = Enum('Color', ['red', 'green', 'blue'])
Color = Enum('Color', '''
red
green
blue
''') |
|
Date |
User |
Action |
Args |
2016-09-07 20:01:27 | rhettinger | set | recipients:
+ rhettinger, barry, ezio.melotti, r.david.murray, eli.bendersky, ethan.furman, python-dev, martin.panter, serhiy.storchaka, veky |
2016-09-07 20:01:27 | rhettinger | set | messageid: <1473278487.78.0.155604943047.issue23591@psf.upfronthosting.co.za> |
2016-09-07 20:01:27 | rhettinger | link | issue23591 messages |
2016-09-07 20:01:27 | rhettinger | create | |
|