is 및 equals(==) 연산자는 대부분 동일하지만 동일하지는 않습니다. is 연산자는 두 변수가 동일한 객체를 가리키는지 정의하는 반면 ==기호는 두 변수의 값이 동일한지 확인합니다.
예시 코드
# Python program to
# illustrate the
# difference between
# == and is operator
# [] is an empty list
list1 = []
list2 = []
list3=list1
if (list1 == list2):
print("True")
else:
print("False")
if (list1 is list2):
print("True")
else:
print("False")
if (list1 is list3):
print("True")
else:
print("False")
출력
True False True