Nikolay Blokhin Facebook Nikolay Blokhin Instagram Nikolay Blokhin Linkedin Nikolay Blokhin Twitter

Hi, I'm Nikolay Blokhin I build the cool things with Python and Swift

Python: "==" vs "is"

The newbies in Python confuse operators "==" and "is". And sometimes them even thinking that it's the same thing. But this is wrong. It's different.

The simple rule is:

>>> first = ['a', 'b', 'c', 'd'] >>> second = first >>> first == second True >>> first is second True
>>> third = ['a', 'b', 'c', 'd'] >>> first == third True >>> first is third False