title: how to compare two objects in class using __cmp__ method in Python?
body: <pre><code>class Box(object):
  def __init__(self, ival):
      self.value = ival
  def __cmp__(self,other):
      if self.value &lt; other:
          return 
      elif self.value &gt; other:
          return 1
      else:return 0
  </code></pre>
  
  <p>But when I wanna test the program with :</p>
  
  <pre><code>Box(2) &lt; Box(2)
  Box(2) &lt;= Box(2)
  Box(1) &gt;= Box(2)
  Box(3) &gt; Box(2)
  Box(0) == Box(1)
  Box(0) != Box(0)
  </code></pre>
  
  <p>Part of the code below:</p>
  
  <pre><code>Box(1) &gt;= Box(2)
  Box(3) &gt; Box(2)
  Box(0) == Box(1)
  </code></pre>
  
  <p>has shown </p>
  
  <blockquote>
    <p>TypeError: an integer is required</p>
  </blockquote>
  
  <p>Anyone knows why?</p>
  
  <p>EDITED :I added the -1 before but somehow I deleted it -.-
  sorry for asking such careless question!</p>