Hi Chuck, Thanks for checking that. I am running numpy 1.0.1 in python 2.4 on win32 (xp). Are you on linux? I double checked the behavior in 1.0 and 1.0.1, just to be extra sure, and it thows the IOError in both cases. tim
Charles R Harris wrote: > > > On 12/11/06, *Tim Hirzel* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Hi, > Does anyone know how to get fromfile and tofile to work from a > tempfile.TemporaryFile? Or if its not possible? > > I am getting this: > >>> import tempfile > >>> f = tempfile.TemporaryFile () > >>> f > <open file '<fdopen>', mode 'w+b' at 0x01EE1728> > >>> a = numpy.arange(10) > >>> a.tofile(f) > Traceback (most recent call last): > File "<input>", line 1, in ? > IOError: first argument must be a string or open file > > > Works for me: > > In [16]: f = tempfile.TemporaryFile() > > In [17]: a = ones(10) > > In [18]: a.tofile(f) > > In [19]: f.seek(0) > > In [20]: b = fromfile(f) > > In [21]: b > Out[21]: array([ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]) > > In [22]: f.close() > > What version of numpy are you running? > > Chuck > > > ------------------------------------------------------------------------ > > _______________________________________________ > Numpy-discussion mailing list > [email protected] > http://projects.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
