[Python] is와 ==
in Python
is
변수가 같은 객체를 가리키면 True
is 예시
>>> a = [1,2,3]
>>> b = a
>>> c = [1,2,3]
>>> a is b
True
>>> a is c
False
==
변수가 같은 값을 가지면 True
== 예시
>>> a = [1,2,3]
>>> b = a
>>> c = [1,2,3]
>>> a == b
True
>>> a == c
True
변수가 같은 객체를 가리키면 True
>>> a = [1,2,3]
>>> b = a
>>> c = [1,2,3]
>>> a is b
True
>>> a is c
False
변수가 같은 값을 가지면 True
>>> a = [1,2,3]
>>> b = a
>>> c = [1,2,3]
>>> a == b
True
>>> a == c
True