string to list? possible?

Aahz Maruch aahz at panix.com
Sun Jan 20 15:16:44 EST 2002


In article <mailman.1011555569.13108.python-list at python.org>,
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?

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

The problem is that there's no error checking, and if you're accepting
input from a possibly-hostile source, it could muck with your program or
data files.
-- 
                      --- Aahz  <*>  (Copyright 2002 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

"I support family values -- Addams family values" --www.nancybuttons.com



More information about the Python-list mailing list