Cannot get variable.replace working properly
<p>I am trying to replace a string with a new string in a python file and write the new string permanently to it. When I run the below script it removes part of the string and not all of it. The string in the file is:</p>

<pre><code>self.id = "027FC8EBC2D1"
</code></pre>

<p>And the script I have to replace the string is:</p>

<pre><code>def edit():

    o = open("test.py","r+") #open 
    for line in open("test.py"):   
        line = line.replace("027FC8EBC2D1","NewValue")  
        o.write(line) 
    o.close()

edit()
</code></pre>

<p>Thanks for any help.</p>
