cmp() compares two objects, say, obj1 and obj2 : cmp « Buildin Function « Python Tutorial






# cmp() returns a negative number (integer) if obj1 is less than obj2, 
# cmp() returns a positive number if obj1 is greater than obj2, 
# cmp() returns zero if obj1 is equal to obj2. 

a, b = -4, 12
print cmp(a,b)
print cmp(b,a)
b = -4
print cmp(a,b)
a, b = 'abc', 'xyz'
print cmp(a,b)
print cmp(b,a)
b = 'abc'
print cmp(a,b)

print cmp(-6, 2)
print cmp(-4.333333, -2.718281828)
print cmp(0xFF, 255)








13.7.cmp
13.7.1.cmp() compares two objects, say, obj1 and obj2