Python stops reading file using read
<p>I'm trying to read a binary file and am getting confusing results.</p>

<pre><code>f = open('foo.dat','r')

data = f.read()

print len(data), f.tell()
</code></pre>

<p>The output is:</p>

<pre><code>61, 600
</code></pre>

<p>What is going on here?  Only the first 61 bytes are read, but the file object is telling me that I'm at the end of the file (the file is 600 bytes long).  What happened to the rest of the file?</p>

<p>I just tried reading it in Matlab and it read it in fine so I'm pretty sure the data file is ok.</p>

<p>The documentation mentions something about blocking:  "Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given."  Am I in non-blocking mode?  Seems like that shouldn't matter for a file.  How do I switch to blocking mode?</p>

<p><strong>UPDATE</strong>
@John Machin - Yup! Thank you!  Looks like that is indeed what was going on.  Here's the output:</p>

<pre><code>600, 600
'm\x1aN\x16\x8d\x1e\x96\x10h\x1a'
</code></pre>

<p>The '\x1a' is definitely in there.</p>
