"OSError: cannot write object arrays to a file in binary mode"
<p>It must be one of those days. I have always been able to use function tofile to save data. But for some reason, today it's not working :)</p>

<pre><code>import numpy as np

blah.....

print(type(blist))
npdata = np.array(blist)
print(type(npdata))
npdata.tofile('myfile.dat')
</code></pre>

<p>Gets me the following results:</p>

<pre><code>Traceback (most recent call last):
File "C:/context.py", line 67, in &lt;module&gt;
npdata.tofile('myfile.dat')
OSError: cannot write object arrays to a file in binary mode
&lt;class 'list'&gt;
&lt;class 'numpy.ndarray'&gt;
</code></pre>

<p>So it says I have the file open in binary mode. But I am not opening it in binary mode as far as I know.</p>

<p>EDIT (After Problem solved): I was assuming that blist was a list of integers when I posted this question. Instead it was a list of lists of integers. Problem was that when I created it I was getting a dtype=object instead of dtype=int32 that I was expecting. </p>

<p>Morale: Make sure to use np.append/np.extend correctly and always set the dtype explicitly.</p>