How to convert string to list without eval or exec

William Park opengeometry at yahoo.ca
Tue Mar 9 17:59:39 CET 2004


Oliver Kurz <olku at web.de> wrote:
> 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.

- write to a file
- load the file as module :-)

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data processing and document management.



More information about the Python-list mailing list