[Pythonmac-SIG] Bug in float() ??

Julio Carrerra carrera@wing.net
Tue, 6 Apr 1999 09:35:07 -0400 (EDT)


I think that the problem is that float() is a function that turns a NUMBER
into a float, not a STRING into a float.

-Julio

On Tue, 6 Apr 1999, Erik van Blokland wrote:

> -- Chris Barker, 4/6/99 03 03:
> 
> >import string
> >
> >line = '34.23, 45.43 , 987,   654  '
> >print line
> >
> >data = string.split(line,',')
> >print data
> >
> >data = map(float,data)
> >print data
> 
> 
> I don't think float() works on strings? Nothing to do with whitespace. 
> There's a function in the string module to interpret strings and convert 
> them to floats, atof.
> 
> data = map(string.atof,data)
> 
> print data
> > [34.23, 45.43, 987.0, 654.0]
> 
> 
> hope this helps.
> erik
> 
> 
> erik
> 
> www.letterror.com
> 
> 
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://www.python.org/mailman/listinfo/pythonmac-sig
> 
>