CKTIS / Python
Operator not
Inverts the truth value of its operand and returns a Boolean.
Version: Python 3.14; repository image, production runtime not attested
Syntax
not expressionInverts the truth value of its operand and returns a Boolean.
Use a negated truth test to detect empty containers or false flags. Unlike the two binary Boolean operators, logical negation always returns an actual Boolean.
A custom class can choose its truth value through its Boolean or length method. If neither is present, ordinary instances are truthy.
A nonempty string tests true even if its characters spell a numeric zero.
Syntax
not expression
__bool__, __len__ · not value
Worked example
not [] → True
not "0" → False
Examples
print(not [])
print(not "0")
Result
True False
A nonempty string tests true even if its characters spell a numeric zero.