Getting a clean list from "pyparsing.ParseResults"

I'm currently trying to get the result from pyparsing as a clean list so that I can smooth it out. I read in the documentation that

ParseResults can also be converted to a regular list of strings by calling asList (). Note that this will separate the results of any field names that have been defined for any inline parsing elements. (The pprint module is especially good at printing attached content specified by asList ().)

So, I tried to determine setParseActionwhere I am working on ParseResult

what i get:

>>> print type(tokens.args[0])
 <class 'pyparsing.ParseResults'>
>>> print type(tokens.args[0].asList)
 <type 'instancemethod'>

But I expected / needed the last one from the type list. I have to miss something important when using asList()here.

Dietmar

PS: Here is MTC, what the tokens look like:

>>> print tokens.args[0]
['foo1', ['xxx'], ',', 'graphics={', 'bar1', ['xxx,yyy'], ',', 'bar2', 
['xxx,yyy'], ',', 'bar3', ['xxx,yyy,', 'zzz=baz', ['xxx,yyy']], '}']
+5
2

tokens.args[0].asList - . tokens.args[0].asList() - ( self). , .

+7

 print type(tokens.args[0].asList())
+4

All Articles