Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Keyword True

True is the true singleton of bool, distinct by identity from the integer 1 although both compare equal and have the same hash.

Version: Python 3.14; repository image, production runtime not attested

Syntax

True

True is the true singleton of bool, distinct by identity from the integer 1 although both compare equal and have the same hash.

Test general truth with if or bool rather than requiring identity with True unless an actual Boolean result is the contract.

Like other keywords its name cannot be rebound.

Examples

one = 1
for value in (True, one, "yes"):
    print(bool(value), value is True, value == True)
print(len({True, one}))

Result

True True True
True False True
True False False
1

Like other keywords its name cannot be rebound.

Sources