Python List Variable - Is it using the memory location or something?
<p>I'm trying to pop off the values I'm appending to the list M each time I've evaluated the difference between them and their expected values. I'm printing the result of a list before and after I use <code>M.pop()</code>. Is it using a location in memory and messing up my list inside of deltaL?</p>

<pre><code>M=[]
delta = 3
while abs(delta) &gt; 0.3:
    for num1 in range(450,800,20):
        best_config_per_numL = []
        delta_mL = []
        for config in ['FFF','FFS','FSF','FSS','SFF','SFS','SSF','SSS']:
            M.append(gen(num1,config[0]))
            M.append(gen(num1,config[1]))
            M.append(gen(num1,config[2]))

            xyL = []
            xL = range(400,801,1)
            for i in xL:
                xyL.append([geny(M,i),i])

            deltaL = []
            yL = range(400,801,1)
            for i in range(len(yL)):
                expected = yL[i]
                actual = xyL[i][0].real
                deltaL.append(abs(expected - actual))

            delta_mL.append([max(deltaL),M]) 
            print '\n'+str(delta_mL)+'\n' #&lt;-------------------------- LINE 1
            M.pop()
            M.pop()
            M.pop()
        print '\n'+str(delta_mL)+'\n' #&lt;-------------------------- LINE 2
        best_config_per_numL.append(delta_mL[0].sort()[0]) #best config for all lambda

    M.append(best_config_per_numL.sort()[0][1])
    delta = best_config_per_numL.sort()[0][0]
</code></pre>

<p><strong>The output of LINE 1 is:</strong>
[[1.0, [[1.9736842105263157, 57.0], [1.9736842105263157, 57.0], [1.9736842105263157, 57.0]]]]</p>

<p>[[1.0, [[1.9736842105263157, 57.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]], [0.99749174811000929, [[1.9736842105263157, 57.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]]]</p>

<p>[[1.0, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.99749174811000929, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.90639755394574695, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]]]</p>

<p>[[1.0, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.99749174811000929, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.90639755394574695, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.78984872616045532, [[1.9736842105263157, 57.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]]]</p>

<p>[[1.0, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.9736842105263157, 57.0]]], [0.99749174811000929, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.9736842105263157, 57.0]]], [0.90639755394574695, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.9736842105263157, 57.0]]], [0.78984872616045532, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.9736842105263157, 57.0]]], [0.99749174811000885, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.9736842105263157, 57.0]]]]</p>

<p>[[1.0, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]], [0.99749174811000929, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]], [0.90639755394574695, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]], [0.78984872616045532, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]], [0.99749174811000885, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]], [0.77268527172444679, [[1.0514018691588785, 107.0], [1.9736842105263157, 57.0], [1.0514018691588785, 107.0]]]]</p>

<p>[[1.0, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.99749174811000929, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.90639755394574695, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.78984872616045532, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.99749174811000885, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.77268527172444679, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]], [0.78984872616045532, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.9736842105263157, 57.0]]]]</p>

<p>[[1.0, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.99749174811000929, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.90639755394574695, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.78984872616045532, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.99749174811000885, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.77268527172444679, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [0.78984872616045532, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]], [1.0, [[1.0514018691588785, 107.0], [1.0514018691588785, 107.0], [1.0514018691588785, 107.0]]]]</p>

<p><strong>The output of LINE 2 is:</strong>
[[1.0, []], [0.99749174811000929, []], [0.90639755394574695, []], [0.78984872616045532, []], [0.99749174811000885, []], [0.77268527172444679, []], [0.78984872616045532, []], [1.0, []]]</p>

<p>I expected to get the same thing as LINE 1.</p>
