Pylint complains about comparing a string to a literal with 'is' [duplicate] Pylint complains about comparing a string to a literal with 'is' [duplicate] python-3.x python-3.x

Pylint complains about comparing a string to a literal with 'is' [duplicate]


is checks that the left hand argument holds the exact same reference as the right hand argument. This is fine for None which is a singleton, but is usually a bad idea for other types, where multiple instances can have the same logical value.

Consider, e.g. the following example:

>>> my_string = ''.join([c for c in 'xfje'])>>> print my_stringxfje>>> print my_string == 'xfje'True>>> print my_string is 'xfje'False