<div id="RTEContent">I wrote a small program that compares files test1 and test2 to test3.<br>  If the files are different&nbsp; then it&nbsp; copies either test1 to test3 or the reverse.<br>  <br>  The problem is that the although the shutil.copy2 in thefunction  change_files&nbsp; works without error it does not copy.&nbsp; Can  anyone see what is wrong :-<br>  <br>  def compare_files(file_name1, file_name2):<br>  &nbsp;&nbsp;&nbsp; x = cmp (file_name1, file_name2)<br>  &nbsp;&nbsp;&nbsp; return x<br>  <br>  def open_files(file_name):<br>  &nbsp;&nbsp;&nbsp; file_is = open(file_name,'r')<br>  &nbsp;&nbsp;&nbsp; file_conts = file_is.read()<br>  &nbsp;&nbsp;&nbsp; return file_conts<br>  <br>  def change_files(file_1, file_2):<br>  &nbsp;&nbsp;&nbsp; yesorno = raw_input("Do you want them to be the same Y or N ")<br>  &nbsp;&nbsp;&nbsp; yesorno = string.upper(yesorno)<br>  &nbsp;&nbsp;&nbsp; if yesorno == 'Y':<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try:<br> 
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shutil.copy2(file_1, file_2)<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "copy has been done "<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; except:<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "it did not work"<br>  &nbsp;&nbsp; <br>  <br>  #main<br>  file_name1 = open_files("test1.txt")<br>  file_name2 = open_files("test2.txt")<br>  file_name3 = open_files("test3.txt")<br>  import shutil<br>  import string<br>  <br>  x = compare_files(file_name3, file_name1)<br>  if x != 0:<br>  &nbsp;&nbsp;&nbsp; print&nbsp; "test1 and test3 are different"<br>  &nbsp;&nbsp;&nbsp; change_files("test1.txt", "text3.txt", file_name1)<br>  else:<br>  &nbsp;&nbsp;&nbsp; file_name1 = "test2.txt"<br>  &nbsp;&nbsp;&nbsp; print file_name1<br>  &nbsp;&nbsp;&nbsp; x = compare_files(file_name3, file_name2)<br>  #&nbsp;&nbsp;&nbsp; print "x is " + str(x)<br> 
 &nbsp;&nbsp;&nbsp; if x != 0:<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "test2 and test3 are different"<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; change_files("test2.txt", "text3.txt")<br>  print "program finished"<br>  <br>  </div><BR><BR>--------------------------------------------------------------------------------------------------------------------------------------<br> "<span id="en-NIV-26403" class="sup"></span>Then you will know the truth, and the truth will set you free."<br>  <h3>John 8:32</h3> <span style="font-style: italic;">"</span> As Pastor Niemöller said, first they came for Piglet and I did not speak out because I was not a Disney character."<br>  http://www.telegraph.co.uk/opinion/main.jhtml?xml=/opinion/2005/10/04/do0402.xml<br> <br> "When the facts change, I change my opinions, what do you do sir&nbsp; ?"&nbsp; John Keynes.<br> <br> <br><p>
                <hr size=1><font face="Arial" size="2">To help you stay safe and secure online, we've developed the all new <a href="http://us.rd.yahoo.com/mail/uk/taglines/default/security_centre/*http://uk.security.yahoo.com/"><b>Yahoo! Security Centre</b></a>.</font>