Posted at

Pythonの `==` と `is`

More than 1 year has passed since last update.

===

pythonでテストを書いていてオブジェクト(辞書)の比較で引っかかったのでメモ。

$ python

Python 2.7.11 (default, Oct 6 2016, 09:16:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = { 'a' : 1 }
>>> b = { 'a' : 1 }
>>> a == b
True
>>> a is b
False
>>>

refs.