[Numpy-discussion] Reading and writing binary data to/from file objects

2010-05-26 Thread Christoph Bersch
Hi, I want to read binary data from a file using fromfile. This works as long as I use a file name as argument to fromfile. With a file object the data is wrong! Consider the following example: from numpy import * fname='file.bin' fname2='file2.bin' a = arange(1, 30) print type(a[0]) print

Re: [Numpy-discussion] Reading and writing binary data to/from file objects

2010-05-26 Thread Pauli Virtanen
ke, 2010-05-26 kello 14:07 +0200, Christoph Bersch kirjoitti: f = open(fname2, 'w') [clip] Am I doing something substantially wrong or is this a bug? You are opening files in text mode. Use mode 'wb' instead. -- Pauli Virtanen ___ NumPy-Discussion

Re: [Numpy-discussion] Reading and writing binary data to/from file objects

2010-05-26 Thread Christoph Bersch
Pauli Virtanen schrieb: ke, 2010-05-26 kello 14:07 +0200, Christoph Bersch kirjoitti: f = open(fname2, 'w') [clip] Am I doing something substantially wrong or is this a bug? You are opening files in text mode. Use mode 'wb' instead. That was it, thank you! Linux does not seem to care about