# question about True values

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Fri Oct 27 15:31:39 CEST 2006

```On Fri, 27 Oct 2006 09:16:57 +0000, Antoon Pardon wrote:

>> I think it is a good time to remind people of some extremely well-thought
>> out opposition to the introduction of bools to Python from Laura Creighton:
>>
>> http://mail.python.org/pipermail/python-list/2002-April/095878.html
>>
>> She lost the debate, Guido had the final word and Python now has bools.
>> Take particular note of her description of Python distinguishing between
>> Something ("cat", 4, [0, 1, 2] etc) and Nothing ("", 0, [] etc).
>
> Yes and IMO that is a less usefull distinction than the distinction
> between True and False. When I write code I think in terms of
> conditions. In those conditions this has to be treated this way
> otherwise it has to be treated an other way. Conditions give
> results that are either True or False, not Something or Nothing.

And if you read the thread that Laura Creighton's post is part of, you
will see that she acknowledges that most people think strongly in terms
of binary true/false yes/no states, and that this is often the wrong thing
to do. There are lots of human thought patterns that are unhealthy, and
binary is often one of them.

The world is continuous, and our brains think in binary. No wonder people
have such trouble with concepts like evolution:

- there is a continual chain of individuals such that every offspring of
an reptile is a reptile, and every parent of a mammal is a mammal, and
yet mammals are directly descended from reptiles.

By I digress. This is too easy to get off topic...

> I don't think of 10 > 5 as Something while 5 < 10 would be
> Nothing.

Not at all, you got your operators the wrong way around. Five certainly is
less than 10 in every counting system I've ever come across. I think you
meant 5 > 10 is Nothing.

Certainly purely mathematical relations like GT and LT lend themselves
very well to true two-valued algebra. The thing to remember is that
Python's truth model is not the same as pure Boolean algebra. For
starters, it certainly is not two-valued! It is infinitely-valued. It's
just that many of those values are equivalent *in a Boolean context*.

In Pascal, writing "x := 2; if x then..." would be an error, because x is
not a Boolean. But it is certainly useful to be able to write the
equivalent in Python. The designer of Pascal choose strict Boolean
algebra; the designer of Python choose a more flexible, less strict model.

If you are going to argue for strict Booleans, like in Pascal, then
mathematical relations like GT and LT will be your poster-child.

But if you are going to argue for Python's less strict truth model, then
you'll talk about lots of examples like this:

if somelist:
# work with the list
else:
# nothing to work with

> So while the paradigma of the language may be the
> distinction of Something vs Nothing the programmer will often
> enough think in terms of True and False.

If you read Laura's post, you will see that she is arguing strongly that
thinking about True and False is often -- usually! -- a mistake. I
acknowledge that there are cases where it is either necessary or desirable
to think in terms of True/False, but that is less common than you might
think.

> So IMO it would have
> been better if python had made the distinction between True and
> False and so made the programmer code the Something/Nothing
> disctinction explicitly.

I don't understand what you are saying here, unless it is that you
believe that Python should have strict Pascal-style Booleans.

--
Steven.

```