I was quite surprised when
[] is not []
evaluated to True.
What is happening in this code? What really not and is statements are doing?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
a is not bis a special operator which is equivalent tonot a is b.The operator
a is breturns True if a and b are bound to the same object, otherwise False. When you create two empty lists you get two different objects, soisreturns False (and thereforeis notreturns True).