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

Ben Finney ben+python at benfinney.id.au
Thu Aug 9 05:15:38 CEST 2012

Oleg Broytman <phd at phdru.name> writes:

> On Thu, Aug 09, 2012 at 02:18:53AM +1000, Ben Finney <ben+python at benfinney.id.au> wrote:
> > What is a compelling use case for checking precisely for True or False?
>    To distinguish False and None for a tri-state variable that can
> have 3 values - "yes", "no" and "unspecified" - True, False and None
> in Python-speak.

Since True and False are strongly coupled with a *two*-state type, that
just seems needlessly confusing to the reader of the code. Better to use
a non-bool type which makes it explicit that there are three valid

 \           “In case you haven't noticed, [the USA] are now almost as |
  `\     feared and hated all over the world as the Nazis were.” —Kurt |
_o__)                                                   Vonnegut, 2004 |
Ben Finney

More information about the Python-ideas mailing list