is there an easy way to parse a nested list ?

Vlastimil Brom vlastimil.brom at gmail.com
Mon Mar 16 10:29:57 CET 2009


2009/3/16 Vlastimil Brom <vlastimil.brom at gmail.com>:
> 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
>>
>
> there is a "nestedExpr" (and probably other options, I'm not aware of ...:-)
> ...
> regards
> vbr
>
Well, I thought, there was something already there in the examples for
pyparsing, but couldn't find it first.
check the selective pyparsing evaluator, which also supports lists:

http://pyparsing.wikispaces.com/file/view/parsePythonValue.py

vbr



More information about the Python-list mailing list