[Python-ideas] Programming recommendations (PEP 8) and boolean values

Mike Meyer mwm at mired.org
Sat Aug 11 05:47:54 CEST 2012

Am I the only one that noticed this?

PEP 8 says: "Don't compare boolean values to True or False using ==."

To me, all the talk about wanting to test variables that might not
hold True of False (i.e. - True/False/None or True/False/String or
...) are off topic, as those values *aren't* boolean values. So this
bit of the PEP doesn't really apply to those cases. Some of the
responses have touched on this by saying you should check that the
values are/aren't boolean before testing them, which would mean the
above would apply to the tests on the boolean branch. But the
arguments are all couched in terms of better style, as opposed whether
or not the this rule in the PEP actually applies.

Am I wrong here?  Has my exposure to Hindley-Milner type systems
tainted me to the point where I just don't get it any more?


More information about the Python-ideas mailing list