if x:, vs if x == True, vs if x is True
The following values in Python are false in the context of if and other logical contexts: False None numeric values equal to 0, such as 0, 0.0, -0.0 empty strings: ” and u” empty containers (such as lists, tuples and dictionaries) anything that implements __bool__ (in Python3) to return False, or __nonzero__ (in Python2) to … Read more