[Tutor] accessing list from a string
metolone+gmane at gmail.com
Tue Nov 25 15:59:13 CET 2008
"Bryan Fodness" <bryan.fodness at gmail.com> wrote in message
news:fbf64d2b0811250641i208054f6h2a8f965942b356f0 at mail.gmail.com...
> I have a list in a text file that is in the python format.,
> Positions = [2.5,2.8]
> and would like to grab the values.
> for line in file('list.txt'):
> if line == Positions:
> I know this does not work. Is there a direct way to get my x1 and x2
>>> line = '[2.5,2.8]'
>>> x1,x2 = eval(line)
More information about the Tutor