string to list? possible?
Cliff Wells
logiplexsoftware at earthlink.net
Mon Jan 21 17:07:35 EST 2002
On Mon, 21 Jan 2002 20:16:16 -0000
Julius Welby wrote:
> "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.
shorter:
s = "[1,2,3,4,5]"
l = eval(s)
--
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308
More information about the Python-list
mailing list