thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

tofile ought to support anything with a 'write' method (migrated from Trac #1652) #3203

Closed thouis closed 12 years ago

thouis commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/1652 Reported 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(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

See also: http://projects.scipy.org/numpy/ticket/949

thouis commented 12 years ago

Comment in Trac by atmention:pv, 2010-10-28

Duplicate of #1634