string to list? possible?

Julius Welby jwelby at waitrose.com
Mon Jan 21 15:16:16 EST 2002


"maximilianscherr" <MaximilianScherr at T-Online.de> wrote in message
news:mailman.1011555569.13108.python-list at python.org...
> i need to convert a string like "[1, 2, 3, 4]" to a list [1, 2, 3, 4].
> possible?
>
>

x = "[1,2,3,4,5]"
x = "x=" + x
exec(x)

Probaby just as bad or worse security wise than eval, and more
complicated....but I just had to post. Sorry.

Redundantly-ly yrs,

Julius





More information about the Python-list mailing list