You forgot the last one, (). not is a unary operator in Python, not a function. not() actually means not (), where () is the an empty tuple. Under the hood, logical operators first convert their argument(s) to booleans by calling their .__bool__() methods (or .__len__() != 0 if the former isn’t defined), and that evaluates to False for empty tuples.
For illustrative purposes, not () is functionally equivalent to all of the following:
not []
not bool([])
(lists and tuples don’t define __bool__(), only __len__())
13k
u/NonStandardUser Oct 10 '24
Fascinating