Newbie question

Tommy Grav tgrav at mac.com
Mon Mar 5 11:15:15 EST 2007


Hi list,

    this is somewhat of a newbie question that has irritated me for a  
while.
I have a file test.txt:

0.3434  0.5322 0.3345
1.3435  2.3345 5.3433

and this script
lines = open("test.txt","r").readlines()
for line in lines:
    (xin,yin,zin) = line.split()
    x = float(xin)
    y = float(yin)
    z = float(zin)

Is there a way to go from line.split() to x,y,z as floats without  
converting
each variable individually?

Cheers
    Tommy



More information about the Python-list mailing list