This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients docs@python, steven.daprano
Date 2022-02-28.15:18:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646061498.87.0.521811715231.issue46883@roundup.psfhosted.org>
In-reply-to
Content
There is a long-standing tradition, going back to Python 1.x days before we had dedicated True and False values, to use the lowercase "true" and "false" to mean *any value that duck-types as True* and *any value that duck-types as False* in a boolean context.

Other terms for this same concept include "truthy/falsey" and using true/false as adjectives rather than nouns, e.g. "a true value".

But I am not sure whether this is actually written down anywhere in the documentation.

It would be useful for those who are not aware of the convention (e.g. beginners and people coming from other languages) if the Glossary had entries for lowercase "true" and "false" that explained the usage and referred back to PEP 285. See for example #46882 where this came up.

I suggest something like the following:

boolean context
  Code such as ``if condition:`` and ``while condition:`` which causes the expression ``condition`` to be evaluated as if it were a :class:`bool`.

false
  Any object which evaluates to the :class:`bool` singleton ``False`` in a :term:`boolean context`. Informally known as "falsey". See :term:`true` and :pep:`285`. Among the builtins , false values include ``None``, empty containers and strings, and zero numbers.

true
  Any object which evaluates to the :class:`bool` singleton ``True`` in a :term:`boolean context`. Informally known as "truthy". See :term:`false` and :pep:`285`. Among the builtins , true values include non-empty containers and strings, non-zero numbers (including NANs), and all other objects by default.
History
Date User Action Args
2022-02-28 15:18:18steven.dapranosetrecipients: + steven.daprano, docs@python
2022-02-28 15:18:18steven.dapranosetmessageid: <1646061498.87.0.521811715231.issue46883@roundup.psfhosted.org>
2022-02-28 15:18:18steven.dapranolinkissue46883 messages
2022-02-28 15:18:18steven.dapranocreate