On 07/27/2017 07:15 PM, Steve D'Aprano wrote:

I has some Enums:

from enum import Enum
class X(Enum):
     Falsey = 0
     Truthy = 1
     Fakey = 2


and I want bool(X.Falsey) to be False, and the others to be True. What should I
do?

class X(Enum):
    Falsey = 0
    Truthy = 1
    Fakey = 2
    def __bool__(self):
        return bool(self.value)

--
~Ethan~

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to