Built-in Constants
True — affirmative Boolean singleton
True is the affirmative value of bool, with only one such object. Predicates and conditions use truth testing, so a truthy value need not be True itself. Since bool inherits int, True participates in arithmetic as one and compares and hashes like the integer 1; using both as dictionary keys therefore addresses the same entry. The results of ordinary integer arithmetic need not have type bool. Use explicit bool() when a Boolean result is required, and use is True only when the exact Boolean singleton is the contract. True is reserved syntax, not a configurable name.
Formal Syntax & Structure
python syntaxpython
TrueReturn Value
bool
The affirmative Boolean singleton.
Working Example
Example Snippetpython
flags = {True: "enabled"}flags[1] = "updated"print(len(flags), flags[True])print(bool("ready") is True)print(True + True, type(True + True).__name__)