<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1652" rel="nofollow">http://projects.scipy.org/numpy/ticket/1652</a> on 2010-10-28 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gerritholl/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gerritholl">@gerritholl</a>, assigned to unknown.</em></p>
<p dir="auto">It would be good if .tofile() supported anything with a write-method. I was debugging my code and wanted to see exactly what my_array.tofile(sys.stdout, ' ') would write. However, as I was working in WingIDE, sys.stdout was actually a StringIO, and this code failed.</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">type(r[field])</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">&lt;type 'numpy.float32'&gt;</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">sys.stdout</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">&lt;StringIO.StringIO instance at 0x161a170&gt;</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">r[field].tofile(sys.stdout, ' ', '%s')</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">Traceback (most recent call last):</p>
<p dir="auto">File "", line 1, in </p>
<p dir="auto">IOError: first argument must be a string or open file</p>
<p dir="auto">See also: <a href="http://projects.scipy.org/numpy/ticket/949" rel="nofollow">http://projects.scipy.org/numpy/ticket/949</a></p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1634" rel="nofollow">http://projects.scipy.org/numpy/ticket/1634</a> on 2010-10-11 by trac user foobaron, assigned to unknown.</em></p>
<p dir="auto">aArray = numpy.fromfile(signalfile, numpy.dtype('u1'), number_of_bytes)</p>
<p dir="auto">signalfile = &lt;StringIO.StringIO instance at 0xa0008ec&gt;1<br>
--&gt;<br>
IOError: first argument must be an open file</p>
<p dir="auto">used python version: 2.6.5</p>