PEP 285: Adding a bool type

Terry Reedy tejarex at yahoo.com
Sun Mar 31 20:40:39 EST 2002


"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1017602330.26032.python-list at python.org...
> [Aahz]
> > But what do you think of changing bool() to truth()?
>
> Whatever Guido tells me to think <wink>.  Before then, I think
"bool"
> usually reads better, as it's less a strain to use as either
adjective or
> noun.  Contrast, e.g.,
>
>     isatty returns bool
>     isatty returns a bool
>     isatty returns a bool value
>
> with
>
>     isatty returns truth

I call this a tie, though I really might lean towards 'truth' here
(but maybe not).

>     isatty returns a truth

I admit 'bool' wins here.

>     isatty returns a truth value

I think 'truth' wins this one.  Try this quiz on someone less familiar
with 'bool' than we are.

> After reading "isatty returns a truth", I'm left wondering which
specific
> truth it returns, and whether I'd agree with it <wink>.
>
> Strangely enough, even today:
>
> >>> print os.isatty.__doc__
> isatty(fd) -> Boolean
> Return true if the file descriptor 'fd' is an open file descriptor
> connected to the slave end of a terminal.
> >>>
>
>     isatty(fd) -> truth
>
> doesn't read poorly, though.

Agreed ;<)

My proposal has two parts: do not use 'bool'; do use 'truth' (or
possibly something else such as 'binary' or even 'tval').  I am
curious what you think of the four reasons I gave.  I am specifically
curious whether you will volunteer to anwer a multiyear stream
(already started) of questions about why Python truth values, being
called bool, do not act 'properly' as bools 'should' and suggestion
that they 'ought' to be restricted (crippled) so that they do.

For some (many? most?) people, it's obvious now, 'Boolean' and its
derivative 'bool' have a definite and restricted usage that excludes
Python truth values current and proposed.  Perhaps we should honor
that usage and use something either more general or more specific to
Python.  Otherwise, we had bettter say pretty clearly that Python bool
is not Boolean and that one should think of it as a type with dual
inheritance from both int and (abstract, not implemented) Boolean.
(And expect that people will be mislead anyway.)

Terry J. Reedy







More information about the Python-list mailing list