title: Python: change elements position in a list of instances
body: <p>I have a list that is made of class instances:</p>
  
  <pre><code>MyList = [&lt;instance1&gt;, &lt;instance2&gt;, &lt;instance3&gt;]
  </code></pre>
  
  <p>I would like to change the position of the third element, <code>&lt;instance3&gt;</code>, that should now stay in the position index = 1, so with the following output:</p>
  
  <pre><code>MyList = [&lt;instance1&gt;, &lt;instance3&gt;, &lt;instance2&gt;]
  </code></pre>
  
  <p>I have built a simple example that works:</p>
  
  <pre><code>a = [1,2]
  b = [3,4]
  c = [5,6]
  d = [a,b,c]
  </code></pre>
  
  <p>The code above gives me the following <code>print d</code> output:</p>
  
  <pre><code>d = [[1, 2], [3, 4], [5, 6]]
  </code></pre>
  
  <p>I'm able to swap the elements (1) and (2) with the following method: </p>
  
  <pre><code>d.remove(c)
  d.insert(c,1)
  </code></pre>
  
  <p>which gives me the following output (that is the one that I want): </p>
  
  <pre><code>d = [[1, 2], [5, 6], [3, 4]]
  </code></pre>
  
  <p>However, when I try to make the same with my list of instances, I get the following AttributeError: </p>
  
  <pre><code>AttributeError: entExCar instance has no attribute '__trunc__'
  </code></pre>
  
  <p>Someoene can tell me if I'm wrong in the method (example: you cannot use this technique with list of instances, you should rather do "this or that") or in the way I'm setting the code? The following script is the actual code I'm trying to run getting the error: </p>
  
  <pre><code>newElement = self.matriceCaracteristiques[kk1]    
  self.matriceCaracteristiques.remove(newElement) 
  self.matriceCaracteristiques.insert(newElement,nbConditionSortieLong)   
  </code></pre>
  
  <p>Thanks in advance.       </p>
  
  <p><em>EDIT: SOME DETAILS MORE</em></p>
  
  <p>entExCar is the class which is being instatiating 
  self.matriceCaracteristiques is the list I want to manipulate
  newElement is the element I want to remove from its original position (kk1) and put back into the new position (nbConditionSortieLong).                                 </p>