#coding=utf-8
#比較兩個對象是否相等
#python 2中使用cmp(),==,is
#is 主要是判斷 2 個變量是否引用的是同一個對象,如果是的話,則返回 true,否則返回 false。
#== 用來判斷兩個對象的值是否相等(跟 Java 不同,Java 中 == 用來判斷是否是同一個對象)
a = 256
b = 256
print id(a)
print id(b)
print a is b
print a==b
print "cmp(80, 100) : ", cmp(80, 100)
print "cmp(180, 100) : ", cmp(180, 100)
print "cmp(-80, 100) : ", cmp(-80, 100)
print "cmp(80, -100) : ", cmp(80, -100)
#python 3中使用operator
#>>> import operator
#>>> operator.eq("hello","name")
#False
#>>> operator.eq("hello","hello")
#True
#>>>