Skip to content

Use "zero of any numeric type" instead of "numeric zero of all types" in "Truth Value Testing" section #148444

@siliconforks

Description

@siliconforks

Documentation

In the documentation for "Truth Value Testing" at https://docs.python.org/3/library/stdtypes.html#truth it says that the following are considered false:

  • constants defined to be false: None and False
  • zero of any numeric type: 0, 0.0, 0j, Decimal(0), Fraction(0, 1)
  • empty sequences and collections: '', (), [], {}, set(), range(0)

This seems correct. No problems there.

However, in the documentation for "Boolean operations" at https://docs.python.org/3/reference/expressions.html#boolean-operations it says that the following are considered false:

False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets).

This seems misleading to me. The wording is similar to the documentation for "Truth Value Testing", but note the difference between "zero of any numeric type" and "numeric zero of all types". The latter appears to suggest that '0' (a string containing the character zero) might be considered false, but of course it is considered true in Python.

I would suggest changing "numeric zero of all types" to "zero of any numeric type" (or "zero of all numeric types") to be consistent with the rest of the documentation (and to be consistent with the actual behavior of Python).

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions