Message287910
Consider:
--------
class AllEnum(Enum):
@classattr
def ALL(cls):
members = list(cls)
all_value = None
if members:
all_value = members[0]
for member in members[1:]:
all_value |= member
cls.ALL = all_value
return all_value
class Color(AllEnum, Flag):
RED = auto()
BLUE = auto()
GREEN = auto()
class IntColor(AllEnum, IntFlag):
RED = auto()
BLUE = auto()
GREEN = auto()
--------
The Color class works fine, but the IntColor fails. This is due to the way the base data type and __new__ method is discovered. If we switch the order of the bases
class IntColor(IntFlag, AllEnum)
it works, but having to put the mixin class last is both bizarre and unworkable when the mixin should be overriding behavior. |
|
Date |
User |
Action |
Args |
2017-02-16 02:09:44 | ethan.furman | set | recipients:
+ ethan.furman, barry, eli.bendersky |
2017-02-16 02:09:44 | ethan.furman | set | messageid: <1487210984.19.0.348647583319.issue29577@psf.upfronthosting.co.za> |
2017-02-16 02:09:44 | ethan.furman | link | issue29577 messages |
2017-02-16 02:09:43 | ethan.furman | create | |
|