Boolean comparison & PEP8

Michael Torrie torriem at gmail.com
Sun Jul 28 22:01:38 EDT 2019


On 7/28/19 6:04 PM, Chris Angelico wrote:
> This is a fairly unusual case, though. More commonly, the default
> would be None, not False, and "if bar is None:" is extremely well
> known and idiomatic.

Ahh yes, true.

> This analysis is correct, but the situations where you *actually* want
> to know if something "is True" or "is False" are rare enough that PEP
> 8 doesn't need to mention them; whereas the case where you actually
> just need the truthiness is so common (and so often miswritten) that
> it's worth being clear on it.

It may well be that a distinct sentinel object is preferred to True or
False in the majority of cases.




More information about the Python-list mailing list