In the following cases:
test = False
test = ""
test = 0
test = 0.0
test = []
test = ()
test = {}
test = set()
the if
test will differ:
if test: #False
if test is not None: #True
This is the case because is
tests for identity, meaning
test is not None
is equivalent to
id(test) == id(None) #False
therefore
(test is not None) is (id(test) != id(None)) #True
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…