title: how to remove a object in a python list
body: <p>I create a class named <code>point</code> as following:</p>
  
  <pre><code>class point:
      def __init__(self):
          self.x = 0
          self.y = 0
  </code></pre>
  
  <p>and create a list of <code>point</code> instances:</p>
  
  <pre><code>p1 = point()
  p1.x = 1
  p1.y = 1
  p2 = point()
  p2.x = 2
  p2.y = 2
  p_list = []
  p_list.append(p1)
  p_list.append(p2)
  </code></pre>
  
  <p>Now I'd like remove from the list the instance which <code>x = 1</code> and <code>y = 1</code>, how can I do this?</p>
  
  <p>I try to add a <code>__cmp__</code> method for class <code>point</code> as following:</p>
  
  <pre><code>class point:
      def __init__(self):
          self.x = 0
          self.y = 0    
      def __cmp__(self, p):
          return self.x==p.x and self.y==p.y
  </code></pre>
  
  <p>But the following code does not work</p>
  
  <pre><code>r = point()
  r.x = 1
  r.y = 1
  if r in p_list:
      print('correct')
  else:
      print('wrong') # it will go here
  p_list.remove(r) # it reports 'ValueError: list.remove(x): x not in list'
  </code></pre>