Basic question
Max M
maxm at mxm.dk
Mon May 14 09:25:02 EDT 2007
Dmitry Dzhus skrev:
>> Actually I'm trying to convert a string to a list of float numbers:
>> str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0]
>
> str="53,20,4,2"
> map(lambda s: float(s), str.split(','))
>
> Last expression returns: [53.0, 20.0, 4.0, 2.0]
The lambda is not needed there, as float is a callable.
map(float, str.split(','))
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Python-list
mailing list