is there an easy way to parse a nested list ?

Vlastimil Brom vlastimil.brom at gmail.com
Mon Mar 16 04:05:56 EDT 2009


2009/3/16 Stef Mientki <stef.mientki at gmail.com>:
> hello,
>
> I need to parse a nested list, given as a string, like this
>
> line = " A  [  B  [ C+2 ] + 3 ] "
>
...
>
> thanks,
> Stef
>

Hi,
I guess, you can use e.g. pyparsing;
there is a "nestedExpr" (and probably other options, I'm not aware of ...:-)
Check the example
http://pyparsing.wikispaces.com/file/view/nested.py
 or othere to see, if you can adapt it for your needs.

regards
vbr



More information about the Python-list mailing list