A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/317175.html below:

String from File -> List without parsing

String from File -> List without parsingJean-François Doyon jfdoyon at methane.ca
Sun Sep 4 14:08:59 EDT 2005
Gregor,

You want to use eval():

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> eval('[3,54,5]')
[3, 54, 5]
 >>>

Cheers,
J.F.

Gregor Horvath wrote:
> Hi,
> 
> given the dynamic nature of python I assume that there is an elegant 
> solution for my problem, but I did not manage to find it.
> 
> I have a file that contains for example on line:
> 
> ['147', '148', '146']
> 
> when I read the file
> 
>  f = file("I050901.ids").readlines()
> 
> I have a string
> 
> f[0] == "['147', '148', '146']"
> 
> How can I turn this string into a list
> 
> li == ['147', '148', '146']
> 
> without parsing?
> 
> -- 
> Greg

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4