Package pyparsing :: Module pyparsing :: Class ParseResults |
[frames] | no frames]

# Class ParseResults

source code

    object --+
             |
            ParseResults

Structured parse results, to provide multiple means of access to the parsed data:

- as a list (`len(results)`)
- by list index (`results[0], results[1]`, etc.)
- by attribute (`results.<resultsName>`)

Instance Methods
__init__(self, toklist, name=None, asList=True, modal=True, isinstance=<built-in function isinstance>) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
__getitem__(self, i) | source code
__setitem__(self, k, v, isinstance=<built-in function isinstance>) | source code
__delitem__(self, i) | source code
__contains__(self, k) | source code
__len__(self) | source code
__bool__(self) | source code
__nonzero__(self) | source code
__iter__(self) | source code
__reversed__(self) | source code
keys(self) Returns all named result keys. | source code
pop(self, index=-1) Removes and returns item at specified index (default=last). | source code
get(self, key, defaultValue=None) Returns named result matching the given key, or if there is no such name, then returns the given `defaultValue` or `None` if no `defaultValue` is specified. | source code
insert(self, index, insStr) Inserts new element at location index in the list of parsed tokens. | source code
items(self) Returns all named result keys and values as a list of tuples. | source code
values(self) Returns all named result values. | source code
__getattr__(self, name) | source code
__add__(self, other) | source code
__iadd__(self, other) | source code
__radd__(self, other) | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
asList(self) Returns the parse results as a nested list of matching tokens, all converted to strings. | source code
asDict(self) Returns the named parse results as dictionary. | source code
copy(self) Returns a new copy of a `ParseResults` object. | source code
asXML(self, doctag=None, namedItemsOnly=False, indent=`'````'`, formatted=True) Returns the parse results as XML. | source code
getName(self) Returns the results name for this token expression. | source code
dump(self, indent=`'````'`, depth=0) Diagnostic method for listing out the contents of a `ParseResults`. | source code
__getstate__(self) | source code
__setstate__(self, state) | source code
__dir__(self) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Static Methods
a new object with type S, a subtype of T |
__new__(cls, toklist, name=None, asList=True, modal=True) | source code

Properties
Inherited from `object`: `__class__`

Method Details

### __new__(cls, toklist, name=None, asList=True, modal=True) Static Method | source code
Returns: a new object with type S, a subtype of T Overrides: object.__new__ (inherited documentation)

### __init__(self, toklist, name=None, asList=True, modal=True, isinstance=<built-in function isinstance>) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### pop(self, index=-1) | source code
Removes and returns item at specified index (default=last). Will work with either numeric indices or dict-key indicies.

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

### asXML(self, doctag=None, namedItemsOnly=False, indent=`'````'`, formatted=True) | source code
Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.

### dump(self, indent=`'````'`, depth=0) | source code
Diagnostic method for listing out the contents of a `ParseResults`. Accepts an optional `indent` argument so that this string can be embedded in a nested display of other data.