PEP 285: Adding a bool type

Pearu Peterson pearu at cens.ioc.ee
Sun Mar 31 16:26:33 EST 2002


On 31 Mar 2002, Stefan Schwarzer wrote:

> bools and ints. For example, I consider it very unintutive that
> "True == 1" should by true but "True == 2" should be false. I


Just a random thought ...

Theorem:
========
Assume specification of PEP 285. The following statements hold truth:

  True is One

and

  False is Zero,

where One and Zero represent integers 1 and 0, respectively.

Proof:
------
According to PEP, True and False are instances of bool that is a subclass
of int. Therefore True and False can be considered as integers and it
makes sense to compare them with integers. If n is an integer then the
following statements hold

  True == n   only if n is 1

and

  False == n  only if n is 0.

Note that these statements still hold if n is varied within the set
of all standard Python objects:

  {None} U Tuples U Lists U Strings U Numbers ..

with ==-relation defined as the Python ==-relation when comparing objects
of different types.

Q.E.D.

truth-is-True-is-One-is-1-is-integer-is-bool-really-necessary?'ly

Pearu





More information about the Python-list mailing list