| Store | Cart

How to convert string to list without eval or exec

From: Fuzzyman <mich...@foord.net>
16 Mar 2004 03:37:09 -0800
"Oliver Kurz" <olku at web.de> wrote in message news:<mailman.158.1078818680.19534.python-list at python.org>...
> Hello,> > could someone give me a solution how to convert a string to a list without using eval or exec?> > The string looks like:> > '[["abc","abc",["abc","abc"],"abc"],["abc","abc",["abc","abc"],["abc",["abc","abc"]],"abc"],"abc"]'> > and should be converted to a list:> > [['abc', 'abc', ['abc', 'abc'], 'abc'], ['abc', 'abc', ['abc', 'abc'], ['abc', ['abc', 'abc']], 'abc'], 'abc']> > I'm not allowed to use eval or exec.> > --

I'm not sure if you now have a working answer to this problem... but
as part of configuration file parser I've written a string to list
parser.....

It will parse a line of text into nested lists.... still
'experimental' but it passes the tests I've done so far....

listparse is included as a module in the ConfigObj 2 zip... see :
http://www.voidspace.org.uk/atlantibots/pythonutils.html#configobj


Regards,


Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html

Recent Messages in this Thread
Fuzzyman Mar 16, 2004 11:37 am
Peter Harris Mar 11, 2004 10:28 pm
Messages in this thread