Do not compare strings using "is"
It is a bad idea to do any comparisons in python using is
instead of ==
, unless you are sure you know what you are doing is correct. The reason for that is that the former compares the identity of the object (which you usually do not want), while the latter compares the value. For an example of the confusing behaviour of comparison using is
when comparing strings:
>>> a = "hello"
>>> a is "hello"
True
>>> a = "hello!"
>>> a is "hello!"
False
Edited by Michiel Cottaar