PEP 285: Adding a bool type

Steve Holden sholden at holdenweb.com
Sun Apr 7 11:39:59 EDT 2002


Sorry abt the format of this posting: OE foundit very difficult to remove
Colin's HTML...

"Colin J. Williams" <cjw at sympatico.ca> wrote in message
news:3CAF6EE6.7564CDF7 at sympatico.ca...

Guido asks seven questions:
[Colin provides seven answers]

> Perhaps we should also be rethinking the meaning of None.

Or the meaning of Life ... :-)

> Maybe it would be better to think of it as a NULL in relational
> algebra.
> Suppose we have a person record (p) with attributes age and sex.
> p.age= 22 and p.sex= F       (F asumed to be part of an enumeration)
> then we know something about this person.
> On the other hand, suppose we have p.age= None and p.sex= M
> We know that we have a male of unknown age.
> Suppose now that we ask whether this person's age is greater
> than 25:
>         if p.age > 25: ...
> Currently, the response is False, but really we don't know.
> Thus, it might be better to think in terms of a three value
> system False, Unknown, True.

If you really wanted to go this way (and there are worse options), the
"logical" (no pun intended) value to use for Unknow id clearly None itself.
Relational systems mostly seem to return NULL as the result of operations on
NULL, whether they be comparisons or arithmetic operations.

Note this would introduce three-valued logic into Python, which would be
helluva confusing to beginners, who tend to understand the law of the
excluded middle implicitly.

> The PEP 285 does not appear to envisage sub-classes, but
> they could be useful for people who would prefer to obtain
> No, Yes or N, Y from repr().
> To sum up, having True and False as defined constant values
> would help a little, but in view of the vociferous response
> and the degree of interest, a pause for further review might
> be best.

It's becoming clear to me that Guido's biggest mistake was proposing this as
a PEP. Since none of the arguments expressed as a result have swayed his
opinion that the change is a good thing, he might as well have simply
introduced the change by fiat.

That way he could have ignored the resulting howls of protest rather than
being forced to respond to them. Not much else would be different...

regards
 Steve








More information about the Python-list mailing list