On 08/18/2014 01:58 PM, ElChino wrote:
"Marko Rauhamaa" <ma...@pacujo.net> wrote:

In almost all cases, both tests would result in the same behavior.
However, the "is not" test is conceptually the correct one since you
want to know if x is the one and only None object. You don't want to be
fooled by an imposter object that simply looks like the None object.

Thanks for this excellent answer. "Terve, terve".

I don't know what "terve, terve" means, but the "in almost all cases" is only true when talking about singletons such as None.

If you are not dealing with singletons (which is most cases), such as numbers, strings, lists, and most other arbitrary objects, you will need to use "!=" or anytime the two objects you are comparing are not the exact same object, you can easily get the wrong answer.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to