bool(Enum) should raise ValueError

Erik Aronesty erik at q32.com
Fri Jul 26 14:56:11 EDT 2019


I just spend a while tracking down and killing all "if Enum" and "if not
Enum" bugs in my code.   I was frankly shocked that this didn't raise a
ValueError to begin with.

Apparently all enums are true/false depending on whether the underlying
value is truthy or falsy.

Which breaks the abstraction Enum's are trying to achieve because now the
user of an Enum has to know "stuff" about the underlying value and how it
behaves.



More information about the Python-list mailing list