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

Erik van Blokland erik@letterror.com
Tue, 6 Apr 99 10:37:10 +0200


-- 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