Copying files with Python under Windows
<p>I'm trying to copy files inside a Python script using the following code:</p>

<pre><code>inf,outf = open(ifn,"r"), open(ofn,"w")
outf.write(inf.read())
inf.close()
outf.close()
</code></pre>

<p>This works perfectly unedr OSX (and other UNIX flavors I suspect) but fails under Windows. Basically, the read() call returns far less bytes than the actual file size (which are around 10KB in length) hence causing the write truncate the output file.</p>

<p>The description of the read() method says that "If the size argument is negative or omitted, read all data until EOF is reached" so I expect the above code to work under any environment, having Python shielding my code from OSs quirks.</p>

<p>So, what's the point? Now, I resorted to shutil.copyfile, which suits my need, and it works. I'm using Python 2.6.5</p>

<p>Thank you all.</p>
