Weird behaviour of `not` operator with python list
问题 When I'm trying to check whether a list is empty or not using python's not operator it is behaving in a weird manner. I tried using the not operator with a list to check whether it is empty or not. >>> a = [] >>> not (a) True >>> not (a) == True True >>> not (a) == False True >>> True == False False The expected output for not (a) == False should be False. 回答1: == has higher precedence than not . not (a) == False is parsed as not (a == False) . 回答2: This is working as expected. Parenthesis