converting lists to strings to lists

robin robin.meier at gmail.com
Wed Apr 12 09:53:23 EDT 2006


hi,

i'm doing some udp stuff and receive strings of the form '0.870000
0.250000 0.790000;\n'
what i'd need though is a list of the form [0.870000 0.250000 0.790000]
i got to the [0:-3] part to obtain a string '0.870000 0.250000
0.790000' but i can't find a way to convert this into a list. i tried
eval() but this gives me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 1
    .870000 0.250000 0.79000

and i have the same problem the other way round. e.g. i have a list
which i need to convert to a string in order to send it via udp.
btw: i cannot use pickle, since i'm sending stuff to a LISP programme.

thank you in advance for your help!
best,

robin




More information about the Python-list mailing list