all Python 3Built-in typesterm
False
special values
Boolean falsehood, the other instance of bool, equal to 0. 0, '', [] and None are falsy too, but only zeros equal False.
Syntax
False
False is a built-in constant you cannot assign to; as an int subclass it equals 0 and is the same dict key as 0. The main trap is mixing up "falsy" and "equal to False": [] == False and None == False are both False, even though both values are falsy in an if. Test emptiness with if not x:, a missing value with x is None, and treat x == False as almost always a bug.
Examples
print(False == 0, False + 1) # → True 1
print(bool([]), [] == False) # → False False — ложно, но не равно False
print(None == False, not None) # → False True
d = {0: 'ноль'}
d[False] = 'ложь' # тот же ключ, что и 0
print(d) # → {0: 'ложь'}
See also
Open in the full glossarydocs.python.orgReport an inaccuracy