converting lists to strings to lists

bruno at modulix onurb at xiludom.gro
Wed Apr 12 11:30:24 EDT 2006


robin wrote:
> yo!
> 
> thank you everone! here's how i finally did it:
> converting the string into a list:
> 
> 	input = net.receiveUDPData()
> 	input = list(eval(input[0:-2]))

You'll run into trouble with this.

> converting the list into a string:
> 
> 	sendout = "%.6f %.6f %.6f;\n" % tuple(winningvector)
> 
> maybe i'll even find a way to generalize the list2string bit, so it
> accepts arbitrary sized lists...

sendout = "%s;\n" % " ".join(["%.6f" % float(s) for s in winningvector])



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list