[NumPy-Tickets] [NumPy] #1652: tofile ought to support anything with a 'write' method

NumPy Trac numpy-tickets@scipy....
Thu Oct 28 13:25:57 CDT 2010


#1652: tofile ought to support anything with a 'write' method
-------------------------+--------------------------------------------------
 Reporter:  gerrit       |       Owner:  somebody
     Type:  enhancement  |      Status:  new     
 Priority:  low          |   Milestone:          
Component:  numpy.core   |     Version:  1.3.0   
 Keywords:               |  
-------------------------+--------------------------------------------------
 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 "<string>", line 1, in <fragment>

  IOError: first argument must be a string or open file

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

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1652>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list