[Numpy-discussion] ValueError: invalid literal for float()

Nils Wagner nwagner at iam.uni-stuttgart.de
Fri Feb 27 10:20:46 EST 2009


Hi all,

Is it possible to modify the behaviour of float wrt
the following situation

  
>>> permas_M[0,2]
'1.5699999809265137D+01'
>>> float(permas_M[0,2])
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): 
1.5699999809265137D+01

The following works.

>>> permas_M[0,2] = '1.5699999809265137E+01'
>>> permas_M[0,2]
'1.5699999809265137E+01'
>>> float(permas_M[0,2])
15.699999809265137

Nils



More information about the NumPy-Discussion mailing list