String To List

Paul Rubin http
Mon Mar 17 09:22:03 CET 2008

Girish <girish.cfc at> writes:
> I have a string a = "['xyz', 'abc']".. I would like to convert it to a
> list with elements 'xyz' and 'abc'. Is there any simple solution for
> this??
> Thanks for the help...

Be careful about using eval, if the string came from a potentially
hostile source.  Maybe what you really want is JSON, which has
python-like syntax but a bunch of safe parsers.

More information about the Python-list mailing list