[SciPy-user] numpy : Fromfile should trigger an exception

Xavier Gnata gnata at obs.univ-lyon1.fr
Fri Feb 24 05:42:26 CST 2006


Hi,

Trying to read more value than those that are available in a binary
file, numpy fromfile function prints a warning message but no exception
is triggered

import numpy
a=numpy.arange(10)
a.tofile('toto.dat')
b = numpy.fromfile('toto.dat',numpy.Int32,11)

shows
11 items requested but only 10 read

But there is no easy way to know that something went wrong (or I'm
missing something).

Xavier

-- 
############################################
Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles André
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 58
Fax: +33 4 78 86 83 86
E-mail: gnata at obs.univ-lyon1.fr
############################################ 



More information about the SciPy-user mailing list