I'm currently trying to get a result from pyparsing as a pure list so I can flatten it. I read in the documentation that
ParseResults can also be converted to an ordinary list of strings by calling asList(). Note that this will strip the results of any field names that have been defined for any embedded parse elements. (The pprint module is especially good at printing out the nested contents given by asList().)
So I tried defining a setParseAction
where I work on the ParseResult
what I get is:
>>> print type(tokens.args[0])
<class 'pyparsing.ParseResults'>
>>> print type(tokens.args[0].asList)
<type 'instancemethod'>
But I was expecting/needing the last one to be of type list. I must be missing something important when using asList()
here.
Dietmar
PS: Here a MTC of what the tokens actually look like:
>>> print tokens.args[0]
['foo1', ['xxx'], ',', 'graphics={', 'bar1', ['xxx,yyy'], ',', 'bar2',
['xxx,yyy'], ',', 'bar3', ['xxx,yyy,', 'zzz=baz', ['xxx,yyy']], '}']