string to list? possible?

Lionel Ulmer bbrox at bbrox.org
Sun Jan 20 21:11:16 CET 2002


On Sun, 20 Jan 2002 19:38:20 -0000, maximilianscherr
<MaximilianScherr at T-Online.de> wrote:
>i need to convert a string like "[1, 2, 3, 4]" to a list [1, 2, 3, 4].
>possible?

>>> a = eval("[1, 2, 3, 4]")
>>> a
[1, 2, 3, 4]

But well, you need to be sure that no syntax errors are in the lists :-)

                 Lionel

-- 
		 Lionel Ulmer - http://www.bbrox.org/



More information about the Python-list mailing list