ตัวดำเนินการ is และ equals(==) ส่วนใหญ่จะเหมือนกันแต่ไม่เหมือนกัน คือตัวดำเนินการกำหนดว่าตัวแปรทั้งสองชี้ไปที่วัตถุเดียวกันหรือไม่ ในขณะที่เครื่องหมาย ==จะตรวจสอบว่าค่าของตัวแปรทั้งสองเหมือนกันหรือไม่
โค้ดตัวอย่าง
# 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