The ABCs of Python: “False,” “True,” Stephen Colbert and Santa Claus

It could reasonably be argued that the two Python keywords True and False are the most important ones. As we noted in Are Booleans from Outer Space?, almost everything in Python boils down to these concepts. Let’s start with the latter.

False

False means, as you would expect, “not true.” But that doesn’t quite state the immense importance of False (and, yes, Python wants the word capped). Python has a deeply encoded instinct for falsehoods. Just as Santa Claus knows when you’ve been good or bad, Python knows when you’ve been True or False (at least within confines of basic mathematics).

Python is not, however, strictly mathematical in its reasoning. It has other opinions about False that are only logical from its own computer program perspective. For example, it views the number 0 as False and the number 1 as True. Although this sounds odd, it is logical from a Boolean perspective and turns out to be immensely useful in certain programs.

The following code, when put into your IDLE shell, gives you a taste of how False works:

>>> 7 == 8
False
>>> 9 > 10
False
>>>False == 0
True
>>>False == []
True
>>>[] is []
False

True

This keyword is, of course, the other side of the same coin. Not only does Python tell you when basic mathematical assertions are True, it’ll also perceive some other circumstances as True. The following code gives a sense of how it works:

>>> 5 * 5 == 25
True
>>> 5 + 5 == 10
True
>>> True == 1
True
>>> square = 4
>>> square == 4
True
>>> square == 3
False
[] == []
True

Stephen Colbert

As the former incarnation of Stephen Colbert might have said, that there’s just not enough “truthiness” in Python. You can’t claim something is True just become because it “feels right.” In a way, Python is your anti-Colbert, always basing its arguments on rigorous logic. On the other hand, it’s quite possible to get your computer to tell falsehoods, as long as you correctly evaluate its underlying, internal logic. In this, perhaps, maybe all computers can demonstrate an element of truthiness of which Colbert would be proud.

Featured image: 1881 illustration by Thomas Nast 

Stephen Colbert photo from Montclair Film, https://www.flickr.com/photos/montclairfilmfest/49205031397/

Published by

Mark R. Vickers

I am a writer, analyst, futurist and researcher. I've spent most of my working life as an editor and manager for research organizations focusing on social, business, technology, HR and management trends. But, perhaps more to the point for this blog, I'm curious about the universe and the myriad, often mysterious relationships therein.

Leave a Reply