title: removing an instance of an object in python list
body: <p>I Think this should work but its giving me an error. 
  I have a list that contains objects of class <code>node</code>. I have two different lists </p>
  
  <ol>
  <li>open_list </li>
  <li>node_list.( they are not the same lengthwise, ordering wise)  </li>
  </ol>
  
  <p>When I find a specific node in the <code>open_list</code> I need to delete it from the <code>node_list</code>. I know that the lists have addresses to the objects stored in them </p>
  
  <p>so when i try to do </p>
  
  <pre><code>removed = open_list.pop(min_index) 
  node_list.remove(removed) 
  </code></pre>
  
  <p>it gives me an error saying </p>
  
  <pre><code>node_list.remove(removed)
  ValueError: list.remove(x): x not in list
  </code></pre>
  
  <p>but the list just contains addresses that act like pointers right? it should match up the same addresses. i printed out the address of <code>removed</code> and the whole <code>node_list</code> (only 10 items for now don't fear) 
  print out: (the last item in node_list matches the address of removed: </p>
  
  <pre><code>removed: &lt;__main__.node instance at 0x0124A440&gt;
  node_list: [&lt;__main__.node instance at 0x01246E90&gt;, &lt;__main__.node instance at 0x01246EE0&gt;, &lt;__main__.node instance at 0x0124A300&gt;, &lt;__main__.node instance at 0x0124A328&gt;, &lt;__main__.node instance at 0x0124A350&gt;, &lt;__main__.node instance at 0x0124A378&gt;, &lt;__main__.node instance at 0x0124A3A0&gt;, &lt;__main__.node instance at 0x0124A3C8&gt;, &lt;__main__.node instance at 0x0124A3F0&gt;, &lt;__main__.node instance at 0x0124A418&gt;, &lt;__main__.node instance at 0x0124A440&gt;]
  </code></pre>
  
  <p>Thanks</p>
  
  <p><h3> <b> follow-up Q </b> </h3>    </p>
  
  <p>so I want to check if the node i want to remove exists in the node_list. when i looked up some simple list functions on <a href="http://docs.python.org/tutorial/datastructures.html">http://docs.python.org/tutorial/datastructures.html</a> </p>
  
  <p><code>list.index(x)</code> and <code>remove.index(x)</code> both give an error if the element is not in the list. this caused my program to stop running. 
  to bypass this, can i use this statement before the <code>.remove()</code>: <code>node in node_list</code> i think the <code>in</code> checks to see if an element is part of a list and returns a bool.
  just double checking 
  thanks, </p>