question of style

Terry Reedy tjreedy at udel.edu
Sun Jul 5 15:09:33 EDT 2009


Paul Rubin wrote:

> I don't know what a furphy is, but I don't accept that "somethingness"
> vs. "nothingness" is the same distinction as truth vs falsehood.  True
> and False are values in a specific datatype (namely bool), not
> abstract qualities of arbitrary data structures.  The idea that the
> "if" statement selects between "somethingness" and "nothingness"
> rather than between True and False is a bogus re-imagining of the
> traditional function of an "if" statement and has been an endless
> source of bugs in Python code.  Look how much confusion it causes here
> in the newsgroup all the time.

You appear to be confusing a specific interpretation of an abstraction 
with the abstraction itself. Or perhaps better, you seem to be confusing 
a specific example of a general process with the general process.

A boolean variable is a variable that is in one of two states -- a 
binary variable -- a variable that carries one bit of information. The 
two states are the marked state and the unmarked or default state. Which 
is to say, when we draw a distinction to distinguish two states, we mark 
one of them to distinguish one from the other. The if statement tests 
whether an object is in the marked state (or not).

Truth and falsity of propositions are one possible interpretation of 
marked and unmarked, giving us propositional logic.  But they are only 
one of many. So are in and out of a particular class and member or not 
of a set or subclass or not of a set, giving us class and set logic. So 
are closed and open, said of gates or switches, or on and off, giving us 
switching logic. So are non-zero and zero, said of numbers. Or done and 
not done, said of an algorithmic process.

Counts 0 and 1, and their representations '0' and '1', taken in 
themselves, are as good as any distinct pair as a pair of labels for the 
two distinct states. They have some computational advantages, including 
making it easy to count the number of objects in a collection in the 
marked state (and, given the total number, the number in the unmarked 
state). They have one disadvantage, though. If I say 'x = 1', do I mean 
1 versus 0 or 1 versus all possible ints? Similarly, If 'print(x)' 
prints 1, does it mean 1 versus 0 or 1 versus all other ints? 
Recognizing this, Guido decided to subclass them and give them alternate 
names. He could have chosen 'Marked' and 'Unmarked', or any of several 
other pairs, but did choose the conventional 'True' and 'False', 
referring to the common propositional interpretation. However, he 
specifically disclaimed any intention to restrict 'if' to testing 
specific logic propositions, as opposed to the general proposition 
'object is in the marked state'.

Terry Jan Reedy




More information about the Python-list mailing list