The del statement in python, when applied to a list, does something very strange. It not only deletes the entry in the list in question, but also "backtracks" to delete the same element in whatever list the variable was derived from.
For instance:
>>> x
[1, 2, 3, 4, 5]
>>> z=x
>>> del z[1]
>>> z
[1, 3, 4, 5]
>>> x
[1, 3, 4, 5]
In other words, even though I apply delete to z, the deletion is also applied to x. This "backtracking" doesn't come up with any other commands or functions, e.g.
>>> x=[1,2,3,4,5]
>>> z=x
>>> z+[6]
[1, 2, 3, 4, 5, 6]
>>> x
[1, 2, 3, 4, 5]
applying the add function to z leaves x unaffected, as it very well should.
This is causing me all sorts of headaches with the delete 'NA' scrip that I'm working on. Do you know what's going on with the del statement, and how can I get around this problem so that if I set z=x and then apply del to z, x remains unchanged?