Re: [Python-ideas] Boolean value of an Enum member

Jan. 16, 2016
6:18 p.m.
[resending to lists -- sorry, Greg] On 01/15/2016 12:36 PM, Greg Ewing wrote:
Ethan Furman wrote:
You can start with zero, but unless the Enum is mixed with a numeric type it will evaluate to True. Also, but there are other falsey values that a pure Enum member could have: False, None, '', etc., to name a few. However, as Barry said, writing your own is a whopping two lines of code: def __bool__(self): return bool(self._value_) With Barry and Guido's feedback this issue is closed. Thanks everyone! -- ~Ethan~
3350
Age (days ago)
3350
Last active (days ago)
0 comments
1 participants
participants (1)
-
Ethan Furman