cmp
Python 2
  • cmp(x, y), compare two objects, need to override __cmp__ for user defined type
  • The return value is negative if x < y, zero if x == y and strictly positive if x > y
  • l = [1, 2, 3, 4]
    print cmp(l, [1, 2, 3, 4]) # 0
    		
    Python 3
  • cmp() has been removed in Python 3