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.
type(r[field])
<type 'numpy.float32'>
sys.stdout
<StringIO.StringIO instance at 0x161a170>
r[field].tofile(sys.stdout, ' ', '%s')
Traceback (most recent call last):
File "", line 1, in
IOError: first argument must be a string or open file
Original ticket http://projects.scipy.org/numpy/ticket/1652 on 2010-10-28 by atmention:gerritholl, assigned to unknown.
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.
<type 'numpy.float32'>
<StringIO.StringIO instance at 0x161a170>
Traceback (most recent call last):
File "", line 1, in
IOError: first argument must be a string or open file
See also: http://projects.scipy.org/numpy/ticket/949