I want to convert a string like this:
"asd foo bar ( lol bla ( gee bee ) lee ) ree"
to a list like this:
["asd","foo","bar",["lol","bla",["gee","bee"],"lee"],"ree"]
Is there an easy solution?
edit: It should work for any number and depth of parantheses, but it only has to work for valid strings (no single parantheses)
edit2: Spaces can be seen as delimiters, if it doesn’t match it may raise an error or just not work, I don’t care. It just has to work for well-formed strings.
You can use Python’s parser to do the job. Just help it a little:
If you need it to be safe, use
ast.literal_evalinstead!