reading a list from a file
Tim Williams
tdw at tdw.net
Mon Jun 20 17:38:57 EDT 2005
----- Original Message -----
From: "David Bear" <david.bear at asu.edu>
> I have a file that contains lists -- python lists. sadly, these are not
> pickled. These are lists that were made using a simple print list
> statement.
>
> Is there an easy way to read this file into a list again? I'm thinking I
> would have to
>
>
> I was hoping there was a pythonic way of doing this..
>
a = '[1,2,3,4,5]'
>>> b = eval(a)
>>> b
[1, 2, 3, 4, 5]
>>> b[2]
3
HTH :)
More information about the Python-list
mailing list