[New-bugs-announce] [issue24840] implement bool conversion for enums to prevent odd edge case

Mike Lundy report at bugs.python.org
Tue Aug 11 02:09:32 CEST 2015


New submission from Mike Lundy:

There's a slightly odd edge case which can be summarized as follows:

====================
from enum import Enum

class Bool(Enum):
    Yep = True
    Nope = False

for value in Bool:
    print('%18r is %r' % (value, bool(value)))
====================

output:
====================
  <Bool.Yep: True> is True
<Bool.Nope: False> is True
====================

This isn't really a big deal, but can be made better with the attached patch. I can't think of any odd consequences this might cause, but others may know better.

----------
messages: 248378
nosy: novas0x2a
priority: normal
severity: normal
status: open
title: implement bool conversion for enums to prevent odd edge case
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24840>
_______________________________________


More information about the New-bugs-announce mailing list